This revision was automatically updated to reflect the committed changes.
Closed by commit rG9644368f974a: [clang-tidy] Fix checks filter with
warnings-as-errors (authored by PiotrZSL).
Changed prior to commit:
https://reviews.llvm.org/D146520?vs=543185&id=543222#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D146520/new/
https://reviews.llvm.org/D146520
Files:
clang-tools-extra/clang-tidy/ClangTidy.cpp
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/test/clang-tidy/infrastructure/warnings-as-errors-diagnostics.cpp
Index:
clang-tools-extra/test/clang-tidy/infrastructure/warnings-as-errors-diagnostics.cpp
===================================================================
---
clang-tools-extra/test/clang-tidy/infrastructure/warnings-as-errors-diagnostics.cpp
+++
clang-tools-extra/test/clang-tidy/infrastructure/warnings-as-errors-diagnostics.cpp
@@ -1,12 +1,15 @@
-// RUN: clang-tidy %s -checks='-*,llvm-namespace-comment,clang-diagnostic*' \
+// RUN: clang-tidy %s --checks='-*,llvm-namespace-comment,clang-diagnostic*' \
// RUN: -- -Wunused-variable 2>&1 \
// RUN: | FileCheck %s --check-prefix=CHECK-WARN
-implicit-check-not='{{warning|error}}:'
-// RUN: not clang-tidy %s
-checks='-*,llvm-namespace-comment,clang-diagnostic*' \
-// RUN: -warnings-as-errors='clang-diagnostic*' -- -Wunused-variable 2>&1 \
+// RUN: not clang-tidy %s
--checks='-*,llvm-namespace-comment,clang-diagnostic*' \
+// RUN: --warnings-as-errors='clang-diagnostic*' -- -Wunused-variable 2>&1 \
// RUN: | FileCheck %s --check-prefix=CHECK-WERR
-implicit-check-not='{{warning|error}}:'
-// RUN: not clang-tidy %s
-checks='-*,llvm-namespace-comment,clang-diagnostic*' \
-// RUN: -warnings-as-errors='clang-diagnostic*' -quiet -- -Wunused-variable
2>&1 \
+// RUN: not clang-tidy %s
--checks='-*,llvm-namespace-comment,clang-diagnostic*' \
+// RUN: --warnings-as-errors='clang-diagnostic*' -quiet -- -Wunused-variable
2>&1 \
// RUN: | FileCheck %s --check-prefix=CHECK-WERR-QUIET
-implicit-check-not='{{warning|error}}:'
+// RUN: clang-tidy %s --checks='-*,llvm-namespace-comment'
--warnings-as-errors=* -- \
+// RUN: -Wunused-variable 2>&1 | FileCheck %s
--check-prefix=CHECK-SUPPRESSED \
+// RUN: -implicit-check-not='{{warning|error}}:'
void f() { int i; }
// CHECK-WARN: warning: unused variable 'i' [clang-diagnostic-unused-variable]
@@ -16,3 +19,7 @@
// CHECK-WARN-NOT: treated as
// CHECK-WERR: 1 warning treated as error
// CHECK-WERR-QUIET-NOT: treated as
+
+// CHECK-SUPPRESSED-NOT: unused variable 'i'
+// CHECK-SUPPRESSED: 1 warning generated.
+// CHECK-SUPPRESSED: Suppressed 1 warnings (1 with check filters).
Index: clang-tools-extra/docs/ReleaseNotes.rst
===================================================================
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -106,6 +106,11 @@
- Support specifying `SystemHeaders` in the `.clang-tidy` configuration file,
with the same functionality as the command-line option `--system-headers`.
+- `WarningsAsErrors` (`--warnings-as-errors=`) no longer promotes unlisted
+ warnings to errors. Only the warnings listed in `Checks` (`--checks=`) will
+ be promoted to errors. For custom error promotion, use `-Werror=<warning>`
+ on the compiler command-line, irrespective of `Checks` (`--checks=`)
settings.
+
New checks
^^^^^^^^^^
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
@@ -620,6 +620,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/test/clang-tidy/infrastructure/warnings-as-errors-diagnostics.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/infrastructure/warnings-as-errors-diagnostics.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/warnings-as-errors-diagnostics.cpp
@@ -1,12 +1,15 @@
-// RUN: clang-tidy %s -checks='-*,llvm-namespace-comment,clang-diagnostic*' \
+// RUN: clang-tidy %s --checks='-*,llvm-namespace-comment,clang-diagnostic*' \
// RUN: -- -Wunused-variable 2>&1 \
// RUN: | FileCheck %s --check-prefix=CHECK-WARN -implicit-check-not='{{warning|error}}:'
-// RUN: not clang-tidy %s -checks='-*,llvm-namespace-comment,clang-diagnostic*' \
-// RUN: -warnings-as-errors='clang-diagnostic*' -- -Wunused-variable 2>&1 \
+// RUN: not clang-tidy %s --checks='-*,llvm-namespace-comment,clang-diagnostic*' \
+// RUN: --warnings-as-errors='clang-diagnostic*' -- -Wunused-variable 2>&1 \
// RUN: | FileCheck %s --check-prefix=CHECK-WERR -implicit-check-not='{{warning|error}}:'
-// RUN: not clang-tidy %s -checks='-*,llvm-namespace-comment,clang-diagnostic*' \
-// RUN: -warnings-as-errors='clang-diagnostic*' -quiet -- -Wunused-variable 2>&1 \
+// RUN: not clang-tidy %s --checks='-*,llvm-namespace-comment,clang-diagnostic*' \
+// RUN: --warnings-as-errors='clang-diagnostic*' -quiet -- -Wunused-variable 2>&1 \
// RUN: | FileCheck %s --check-prefix=CHECK-WERR-QUIET -implicit-check-not='{{warning|error}}:'
+// RUN: clang-tidy %s --checks='-*,llvm-namespace-comment' --warnings-as-errors=* -- \
+// RUN: -Wunused-variable 2>&1 | FileCheck %s --check-prefix=CHECK-SUPPRESSED \
+// RUN: -implicit-check-not='{{warning|error}}:'
void f() { int i; }
// CHECK-WARN: warning: unused variable 'i' [clang-diagnostic-unused-variable]
@@ -16,3 +19,7 @@
// CHECK-WARN-NOT: treated as
// CHECK-WERR: 1 warning treated as error
// CHECK-WERR-QUIET-NOT: treated as
+
+// CHECK-SUPPRESSED-NOT: unused variable 'i'
+// CHECK-SUPPRESSED: 1 warning generated.
+// CHECK-SUPPRESSED: Suppressed 1 warnings (1 with check filters).
Index: clang-tools-extra/docs/ReleaseNotes.rst
===================================================================
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -106,6 +106,11 @@
- Support specifying `SystemHeaders` in the `.clang-tidy` configuration file,
with the same functionality as the command-line option `--system-headers`.
+- `WarningsAsErrors` (`--warnings-as-errors=`) no longer promotes unlisted
+ warnings to errors. Only the warnings listed in `Checks` (`--checks=`) will
+ be promoted to errors. For custom error promotion, use `-Werror=<warning>`
+ on the compiler command-line, irrespective of `Checks` (`--checks=`) settings.
+
New checks
^^^^^^^^^^
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
@@ -620,6 +620,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
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits