Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-22764

Clang Code Model does not work with precompiled headers

    XMLWordPrintable

Details

    • Linux/X11

    Description

      The clang code model fails to parse any files which include a precompiled header is included using the -include of the compiler.

      I can reproduce the problem in both 4.9.0 and 4.10.0-beta2. The problem does not seem to appear in 4.8.2.

      When the problem occurs the following error message is printed to the shell, from which the creator has been started:

      Parsing [...]/source.cpp failed: CXError_ASTReadError
      Reparsing [...]/source.cpp failed: 3
      

      Additionally  syntax highlighting does not work correctly, and neither does auto completion, making the IDE nearly unusable.

       

      The following CMakeLists.txt reproduces the problem i have reliably. header.h and source.cpp do not need contain any code.

      configure_file(header.h ${CMAKE_CURRENT_BINARY_DIR}/precompiled_header.h COPYONLY)
      add_custom_command(
          OUTPUT
            ${CMAKE_CURRENT_BINARY_DIR}/precompiled_header.h.gch
          COMMAND
            ${CMAKE_CXX_COMPILER} -x  c++-header ${CMAKE_CURRENT_BINARY_DIR}/precompiled_header.h -o ${CMAKE_CURRENT_BINARY_DIR}/precompiled_header.h.gch
          BYPRODUCTS
            ${CMAKE_CURRENT_BINARY_DIR}/precompiled_header.h.gch)
      add_custom_target(pch
          ALL
          DEPENDS
            ${CMAKE_CURRENT_BINARY_DIR}/precompiled_header.h.gch
          )
      add_library(lib source.cpp)
      add_dependencies(lib pch)
      target_include_directories(lib PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
      target_compile_options(lib PRIVATE -include "${CMAKE_CURRENT_BINARY_DIR}/precompiled_header.h")
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            cadam Cristian Adam
            kaisalm Kai Salm
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes