Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qt Creator enables all warning sets, even though clangd is disabled
Forum Updated to NodeBB v4.3 + New Features

Qt Creator enables all warning sets, even though clangd is disabled

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
6 Posts 2 Posters 215 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sokka
    wrote last edited by sokka
    #1

    Hi all,

    since a few versions ago, the clangd integration in my Qt Creator appears to be extremely buggy. I have warnings on almost every line and the whole editor is swamped with yellow. That includes warning sets that are actively wrong, e.g. "llvmlibc-*" suggesting things that would just break everything, to things that are just irrelevant corporate policy, e.g. "fuchsia-*" whining about default arguments.

    My project is based on qmake .pro files and the preferences in C++ / Clangd are just the default. I already deleted my Qt Creator config / dot files to get rid of settings from many versions ago. Picking either of the built-in Diagnostic Configurations ("Checks for questionable constructs" or "Build-system warnings") doesn't change anything. Neither does creating a new custom configuration with no additional compiler flags. The "Path to executable" for clangd is set to the default, i.e., the clang version shipped along with Qt Creator.

    The worst part: In the previous version I worked around this by simply disabling clangd altogether. I rather have no warnings than this nonsense. However, even if I uncheck Preferences / C++ / Clangd / Use clangd, I still get the all the warnings ever implemented.

    qtcreator warnings.png

    No, it most certainly should not.

    Where is the option to correctly configure this, or at least disable it completely? Is it maybe incorrectly picking up a different clangd version from PATH?

    Side note: half of the URLs to supposed documentation get a 404, e.g. unqualified-std-cast-call -> https://releases.llvm.org/20.1.0/tools/clang/tools/extra/docs/clang-tidy/checks/unqualified/std-cast-call.html.

    EDIT: Qt Creator 17.0.1 on RHEL9 Linux installed in a user (non-root) directory via the Qt Maintenance Tool.

    cristian-adamC 1 Reply Last reply
    0
    • S sokka

      Thanks, I missed that.

      I made a copy of the default configuration, which just had clang-* enabled, but still got results from llvm-*, llvmlibc-*, etc. I disabled everything on Clang-Tidy Checks and Clazy Checks, left the Clang Warnings (just set to "-w") alone.

      Still get all the warnings.

      Using top I see it runs

      qtcreator-17.0.1/libexec/qtcreator/clang/bin/clang-tidy --warnings-as-errors=-* -checks=-clang-diagnostic-* -p /var/tmp/QtCreator-MbWgDG/Clang-TidyjFkxAy [...]
      

      Notably, the checks are always set to "-clang-diagnostic-*" instead of the default of "-*,clang-*" or everything disabled ("-*"), no matter what I do in the settings.

      cristian-adamC Offline
      cristian-adamC Offline
      cristian-adam
      wrote last edited by
      #4

      @sokka Since Qt Creator is open source we can see in clangtooolrunner.cpp :

      static QStringList checksArguments(const AnalyzeUnit &unit, const AnalyzeInputData &input)
      {
          if (input.tool == ClangToolType::Tidy) {
              if (input.runSettings.hasConfigFileForSourceFile(unit.file))
                  return {"--warnings-as-errors=-*", "-checks=-clang-diagnostic-*"};
              switch (input.config.clangTidyMode()) {
              case ClangDiagnosticConfig::TidyMode::UseDefaultChecks:
                  // The argument "-config={}" stops stating/evaluating the .clang-tidy file.
                  return {"-config={}", "-checks=-clang-diagnostic-*"};
              case ClangDiagnosticConfig::TidyMode::UseCustomChecks:
                  return {"-config=" + input.config.clangTidyChecksAsJson()};
              }
          }
          const QString clazyChecks = input.config.checks(ClangToolType::Clazy);
          if (!clazyChecks.isEmpty())
              return {"-checks=" + input.config.checks(ClangToolType::Clazy)};
          return {};
      }
      

      then in clangtoolssettings.cpp:

      bool RunSettings::hasConfigFileForSourceFile(const Utils::FilePath &sourceFile) const
      {
          if (!preferConfigFile())
              return false;
          return !sourceFile.searchHereAndInParents(".clang-tidy", QDir::Files).isEmpty();
      }
      

      I guess this has something to do with a .clang-tidy file somewhere.

      1 Reply Last reply
      0
      • S sokka

        Hi all,

        since a few versions ago, the clangd integration in my Qt Creator appears to be extremely buggy. I have warnings on almost every line and the whole editor is swamped with yellow. That includes warning sets that are actively wrong, e.g. "llvmlibc-*" suggesting things that would just break everything, to things that are just irrelevant corporate policy, e.g. "fuchsia-*" whining about default arguments.

        My project is based on qmake .pro files and the preferences in C++ / Clangd are just the default. I already deleted my Qt Creator config / dot files to get rid of settings from many versions ago. Picking either of the built-in Diagnostic Configurations ("Checks for questionable constructs" or "Build-system warnings") doesn't change anything. Neither does creating a new custom configuration with no additional compiler flags. The "Path to executable" for clangd is set to the default, i.e., the clang version shipped along with Qt Creator.

        The worst part: In the previous version I worked around this by simply disabling clangd altogether. I rather have no warnings than this nonsense. However, even if I uncheck Preferences / C++ / Clangd / Use clangd, I still get the all the warnings ever implemented.

        qtcreator warnings.png

        No, it most certainly should not.

        Where is the option to correctly configure this, or at least disable it completely? Is it maybe incorrectly picking up a different clangd version from PATH?

        Side note: half of the URLs to supposed documentation get a 404, e.g. unqualified-std-cast-call -> https://releases.llvm.org/20.1.0/tools/clang/tools/extra/docs/clang-tidy/checks/unqualified/std-cast-call.html.

        EDIT: Qt Creator 17.0.1 on RHEL9 Linux installed in a user (non-root) directory via the Qt Maintenance Tool.

        cristian-adamC Offline
        cristian-adamC Offline
        cristian-adam
        wrote last edited by
        #2

        @sokka clang-tidy and clazy checks are configured at Preferences > Analyzers > Clang Tools.

        You can then make your own selection of checks.

        qt-creator-analyzer.png

        1 Reply Last reply
        1
        • S Offline
          S Offline
          sokka
          wrote last edited by
          #3

          Thanks, I missed that.

          I made a copy of the default configuration, which just had clang-* enabled, but still got results from llvm-*, llvmlibc-*, etc. I disabled everything on Clang-Tidy Checks and Clazy Checks, left the Clang Warnings (just set to "-w") alone.

          Still get all the warnings.

          Using top I see it runs

          qtcreator-17.0.1/libexec/qtcreator/clang/bin/clang-tidy --warnings-as-errors=-* -checks=-clang-diagnostic-* -p /var/tmp/QtCreator-MbWgDG/Clang-TidyjFkxAy [...]
          

          Notably, the checks are always set to "-clang-diagnostic-*" instead of the default of "-*,clang-*" or everything disabled ("-*"), no matter what I do in the settings.

          cristian-adamC 1 Reply Last reply
          0
          • S sokka

            Thanks, I missed that.

            I made a copy of the default configuration, which just had clang-* enabled, but still got results from llvm-*, llvmlibc-*, etc. I disabled everything on Clang-Tidy Checks and Clazy Checks, left the Clang Warnings (just set to "-w") alone.

            Still get all the warnings.

            Using top I see it runs

            qtcreator-17.0.1/libexec/qtcreator/clang/bin/clang-tidy --warnings-as-errors=-* -checks=-clang-diagnostic-* -p /var/tmp/QtCreator-MbWgDG/Clang-TidyjFkxAy [...]
            

            Notably, the checks are always set to "-clang-diagnostic-*" instead of the default of "-*,clang-*" or everything disabled ("-*"), no matter what I do in the settings.

            cristian-adamC Offline
            cristian-adamC Offline
            cristian-adam
            wrote last edited by
            #4

            @sokka Since Qt Creator is open source we can see in clangtooolrunner.cpp :

            static QStringList checksArguments(const AnalyzeUnit &unit, const AnalyzeInputData &input)
            {
                if (input.tool == ClangToolType::Tidy) {
                    if (input.runSettings.hasConfigFileForSourceFile(unit.file))
                        return {"--warnings-as-errors=-*", "-checks=-clang-diagnostic-*"};
                    switch (input.config.clangTidyMode()) {
                    case ClangDiagnosticConfig::TidyMode::UseDefaultChecks:
                        // The argument "-config={}" stops stating/evaluating the .clang-tidy file.
                        return {"-config={}", "-checks=-clang-diagnostic-*"};
                    case ClangDiagnosticConfig::TidyMode::UseCustomChecks:
                        return {"-config=" + input.config.clangTidyChecksAsJson()};
                    }
                }
                const QString clazyChecks = input.config.checks(ClangToolType::Clazy);
                if (!clazyChecks.isEmpty())
                    return {"-checks=" + input.config.checks(ClangToolType::Clazy)};
                return {};
            }
            

            then in clangtoolssettings.cpp:

            bool RunSettings::hasConfigFileForSourceFile(const Utils::FilePath &sourceFile) const
            {
                if (!preferConfigFile())
                    return false;
                return !sourceFile.searchHereAndInParents(".clang-tidy", QDir::Files).isEmpty();
            }
            

            I guess this has something to do with a .clang-tidy file somewhere.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              sokka
              wrote last edited by
              #5

              That's probably it! I don't have a .clang-tidy file here, so there must be something in the parent directories I'm unaware of.

              Thanks!

              1 Reply Last reply
              0
              • S sokka has marked this topic as solved
              • cristian-adamC Offline
                cristian-adamC Offline
                cristian-adam
                wrote last edited by
                #6

                In the Analyzer preferences page, there is the:

                Prefer .clang-tidy file, if present.

                You could uncheck it and see how things work.

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved