Qt Creator enables all warning sets, even though clangd is disabled
-
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.

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.
-
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.
@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-tidyfile somewhere. -
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.

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.
@sokka clang-tidy and clazy checks are configured at Preferences > Analyzers > Clang Tools.
You can then make your own selection of checks.

-
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.
-
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.
@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-tidyfile somewhere. -
S sokka has marked this topic as solved
-
In the Analyzer preferences page, there is the:
Prefer .clang-tidy file, if present.You could uncheck it and see how things work.