kiwixz created this revision. kiwixz added a reviewer: njames93. kiwixz added a project: clang-tools-extra. Herald added subscribers: PiotrZSL, carlosgalvezp, xazax.hun. Herald added a project: All. kiwixz requested review of this revision. Herald added a subscriber: cfe-commits.
Since commit 5d12b13b0b26bc58b02ee23c369da8b83240cceb <https://reviews.llvm.org/rG5d12b13b0b26bc58b02ee23c369da8b83240cceb>, warnings are internally classified as errors which skip the check filters (see ClangTidyDiagnosticConsumer.cpp:324). One usecase is particularly affected: you cannot selectively disable clang-analyzer-core checks, they are force-enabled because required by others. So enabling warning as errors will show new (and unwanted) errors ! Good: 32693 warnings generated. Suppressed 32693 warnings (32692 in non-user code, 1 with check filters). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. Bad (`-warnings-as-errors=*`): 33057 warnings generated. ... error: Called C++ object pointer is uninitialized [clang-analyzer-core.CallAndMessage,-warnings-as-errors] ... Suppressed 33054 warnings (33054 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 1 warning treated as error As this is a regression from LLVM 15 to LLVM 16, and a simple patch, I hope we can backport it to 16.x series. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D146520 Files: clang-tools-extra/clang-tidy/ClangTidy.cpp clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp =================================================================== --- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp +++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp @@ -421,8 +421,6 @@ bool IsWarningAsError = DiagLevel == DiagnosticsEngine::Warning && Context.treatAsError(CheckName); - if (IsWarningAsError) - Level = ClangTidyError::Error; Errors.emplace_back(CheckName, Level, Context.getCurrentBuildDirectory(), IsWarningAsError); } Index: clang-tools-extra/clang-tidy/ClangTidy.cpp =================================================================== --- clang-tools-extra/clang-tidy/ClangTidy.cpp +++ clang-tools-extra/clang-tidy/ClangTidy.cpp @@ -615,6 +615,8 @@ TUD.MainSourceFile = std::string(MainFilePath); for (const auto &Error : Errors) { tooling::Diagnostic Diag = Error; + if (Error.IsWarningAsError) + Diag.DiagLevel = tooling::Diagnostic::Error; TUD.Diagnostics.insert(TUD.Diagnostics.end(), Diag); }
Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp =================================================================== --- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp +++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp @@ -421,8 +421,6 @@ bool IsWarningAsError = DiagLevel == DiagnosticsEngine::Warning && Context.treatAsError(CheckName); - if (IsWarningAsError) - Level = ClangTidyError::Error; Errors.emplace_back(CheckName, Level, Context.getCurrentBuildDirectory(), IsWarningAsError); } Index: clang-tools-extra/clang-tidy/ClangTidy.cpp =================================================================== --- clang-tools-extra/clang-tidy/ClangTidy.cpp +++ clang-tools-extra/clang-tidy/ClangTidy.cpp @@ -615,6 +615,8 @@ TUD.MainSourceFile = std::string(MainFilePath); for (const auto &Error : Errors) { tooling::Diagnostic Diag = Error; + if (Error.IsWarningAsError) + Diag.DiagLevel = tooling::Diagnostic::Error; TUD.Diagnostics.insert(TUD.Diagnostics.end(), Diag); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits