Skip to content

Commit

Permalink
[include-cleaner] Suppress all clang warnings (#109099)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kadircet authored Sep 19, 2024
1 parent d4536bf commit bb5e66e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// RUN: clang-include-cleaner %s -- -Wunused 2>&1 | FileCheck --allow-empty %s
static void foo() {}

// Make sure that we don't get an unused warning
// CHECK-NOT: unused function
12 changes: 11 additions & 1 deletion clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,17 @@ class Action : public clang::ASTFrontendAction {
}

void ExecuteAction() override {
auto &P = getCompilerInstance().getPreprocessor();
const auto &CI = getCompilerInstance();

// Disable all warnings when running include-cleaner, as we are only
// interested in include-cleaner related findings. This makes the tool both
// more resilient around in-development code, and possibly faster as we
// skip some extra analysis.
auto &Diags = CI.getDiagnostics();
Diags.setEnableAllWarnings(false);
Diags.setSeverityForAll(clang::diag::Flavor::WarningOrError,
clang::diag::Severity::Ignored);
auto &P = CI.getPreprocessor();
P.addPPCallbacks(PP.record(P));
PI.record(getCompilerInstance());
ASTFrontendAction::ExecuteAction();
Expand Down

0 comments on commit bb5e66e

Please sign in to comment.