Skip to content

Commit bb5e66e

Browse files
authored
[include-cleaner] Suppress all clang warnings (llvm#109099)
This patch disables all clang warnings when running include-cleaner, as users aren't interested in other findings and in-development code might have them temporarily. This ensures tool can keep working even in presence of such issues.
1 parent d4536bf commit bb5e66e

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: clang-include-cleaner %s -- -Wunused 2>&1 | FileCheck --allow-empty %s
2+
static void foo() {}
3+
4+
// Make sure that we don't get an unused warning
5+
// CHECK-NOT: unused function

clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,17 @@ class Action : public clang::ASTFrontendAction {
139139
}
140140

141141
void ExecuteAction() override {
142-
auto &P = getCompilerInstance().getPreprocessor();
142+
const auto &CI = getCompilerInstance();
143+
144+
// Disable all warnings when running include-cleaner, as we are only
145+
// interested in include-cleaner related findings. This makes the tool both
146+
// more resilient around in-development code, and possibly faster as we
147+
// skip some extra analysis.
148+
auto &Diags = CI.getDiagnostics();
149+
Diags.setEnableAllWarnings(false);
150+
Diags.setSeverityForAll(clang::diag::Flavor::WarningOrError,
151+
clang::diag::Severity::Ignored);
152+
auto &P = CI.getPreprocessor();
143153
P.addPPCallbacks(PP.record(P));
144154
PI.record(getCompilerInstance());
145155
ASTFrontendAction::ExecuteAction();

0 commit comments

Comments
 (0)