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

Qt Creator clangd reports false errors for headers not included in CMakeLists.txt

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Incomplete
    • Affects Version/s: Qt Creator 6.0.0-beta1
    • Fix Version/s: None
    • Component/s: C/C++/Obj-C++ Support
    • Labels:
      None
    • Environment:
      Operating System: Arch Linux
      The errors occur for C++ stdlib headers as well as Qt 5 and 6 headers.
       I'm using GCC/Clang kits, both stock and modified to use LLD.
    • Platform/s:
      Linux/X11

      Description

      I have some CMake projects where I only include .cpp translation units, but not .h headers, in CMakeLists.txt (so I have to edit CMakeLists.txt less often).

      I installed Qt Creator 6.0.0-beta1 and decided to test the new clangd mode. However, I ran into many false-positive errors in my header files:

      • The first #include in the file has an error "'path' file not found". If you remove it, the error moves to the second #include. This applies to both project includes ("file.h"), Qt headers (<QString>), and C++ stdlib headers (<type_traits>).
      • None of the includes (not even those with no visible errors) were successfully processed. As a result, the rest of the header is filled with errors (unrecognized std::, unrecognized QString and QObject, the Q_OBJECT and signals macros aren't defined).

      These errors do not appear in the previous Clang Code Model, nor when building the project in CMake Ninja GCC/Clang.

      Additionally, when starting Qt Creator and opening any header not found in CMakeLists.txt, I get a "This file is not part of any project" message. Running "Rescan Project" makes the message disappear, but the false errors remain. If I include a header in CMakeLists.txt and "Rescan Project", then the errors go away for that header.

      If I again remove the header from CMakeLists.txt and "Run CMake" or "Rescan Project", the errors remain absent until I restart Qt Creator.

      To make the errors reappear, I must:

      • Remove the header from CMakeLists.txt.
      • "Run CMake" or "Rescan Project" (making the "This file is not part of any project" message reappear, but not the errors).
      • Restart Qt Creator (both the message and the errors appear).

      Is Qt Creator intended to support "not listing headers in CMakeLists.txt, and having the code model infer each header's include paths from which .cpp files include it"?


      Additionally, in both .cpp and .h files, when I type #include <Q, I don't get uppercase includes like <QObject>, but only lowercase ones like <qobject.h>.

        Attachments

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

          Activity

            People

            Assignee:
            kandeler Christian Kandeler
            Reporter:
            nyanpasu64 Nyan Pasu
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes