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

clang code model has trouble finding clang include files when using libc++

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Not Evaluated
    • Qt Creator 4.8.0-beta1
    • Qt Creator 4.6.0
    • C/C++/Obj-C++ Support
    • None
    • * gentoo linux
       ** using clang 6.0 (but I had similar problems with older versions in the past)
       * qbs based project, but I think this is broken for other build tools as well

    Description

      The code model has problems finding files inside clangs resource directory (for example "stddef.h") when the project is using libc++ and a clang kit. See the attachment for a simple qbs based demo project.

      When running qt-creator with 'QT_LOGGING_RULES=qtc.clang*=true' I can see the following output:

      ignoring duplicate directory "/usr/lib64/clang/6.0.0/include"
      #include "..." search starts here:
      #include <...> search starts here:
      /tmp/QtCreator-85XTcw/clang-uiheader-GGBOmg
      /usr/lib64/clang/6.0.0/include
      /usr/include/c++/v1
      /usr/include
      End of search list.

      Libc++ includes "stddef.h" via '#include_next', but because "/usr/lib64/clang/6.0.0/include" is present before "/usr/include/c++/v1" in the search list clang can not find the file.

      Note that clang removed the include directory in the correct place because someone inserted the direcotry already at the top of the list.

      I think this happens inside qt-creator code in 'CompilerOptionsBuilder::addPredefinedHeaderPathsOptions'. As far as I can tell this is not needed with a recent clang version. Clang will add the resource directory to the search path if needed.

      To check this I rebuild qt-creator with the variable 'CLANG_RESOURCE_DIR' inside 'clang_defines.pri' changed to a non existing path - so qt-creator can not add the correct include directory anymore. Then I tried my demo project with different build configurations - they all seem to work correctly. Debug output:
      clang kit, using libc++:

      ignoring nonexistent directory ""
      #include "..." search starts here:
      #include <...> search starts here:
       /tmp/QtCreator-JdXZCP/clang-uiheader-D6ZhTl
       /usr/include/c++/v1
       /usr/lib64/clang/6.0.0/include
       /usr/include
      

      clang kit, using stdlibc++:

      ignoring nonexistent directory ""
      #include "..." search starts here:
      #include <...> search starts here:
       /tmp/QtCreator-JdXZCP/clang-uiheader-D6ZhTl
       /usr/lib64/gcc/x86_64-pc-linux-gnu/7.3.0/include/g++-v7
       /usr/lib64/gcc/x86_64-pc-linux-gnu/7.3.0/include/g++-v7/x86_64-pc-linux-gnu
       /usr/lib64/gcc/x86_64-pc-linux-gnu/7.3.0/include/g++-v7/backward
       /usr/lib64/clang/6.0.0/include
       /usr/include
      

      gcc kit, using stdlibc++:

      ignoring nonexistent directory ""
      #include "..." search starts here:
      #include <...> search starts here:
       /tmp/QtCreator-JdXZCP/clang-uiheader-D6ZhTl
       /usr/lib64/gcc/x86_64-pc-linux-gnu/7.3.0/include/g++-v7
       /usr/lib64/gcc/x86_64-pc-linux-gnu/7.3.0/include/g++-v7/x86_64-pc-linux-gnu
       /usr/lib64/gcc/x86_64-pc-linux-gnu/7.3.0/include/g++-v7/backward
       /usr/lib64/gcc/x86_64-pc-linux-gnu/7.3.0/include
       /usr/lib64/gcc/x86_64-pc-linux-gnu/7.3.0/include-fixed
       /usr/include
      

      Attachments

        Issue Links

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

          Activity

            People

              yvvan Ivan Donchevskii
              cstoitner Christian Stoitner
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes