summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristof Umann <kristof.umann@ericsson.com>2019-08-23 14:57:27 +0000
committerKristof Umann <kristof.umann@ericsson.com>2019-08-23 14:57:27 +0000
commitdabfea85fcca49e8bb4a2690621c1fcea30bd4f3 (patch)
treed92af9adb23cab599ac46133b6657c9ee4eb08d5
parent7d6aa7eb7f58d5df1349ca39700a745a94fec99d (diff)
downloadbcm5719-llvm-dabfea85fcca49e8bb4a2690621c1fcea30bd4f3.tar.gz
bcm5719-llvm-dabfea85fcca49e8bb4a2690621c1fcea30bd4f3.zip
[clang-tidy] Possibility of displaying duplicate warnings
Summary: In case a checker is registered multiple times as an alias, the emitted warnings are uniqued by the report message. However, it is random which checker name is included in the warning. When processing the output of clang-tidy this behavior caused some problems. In this commit the uniquing key contains the checker name too. Reviewers: alexfh, xazax.hun, Szelethus, aaron.ballman, lebedev.ri, JonasToth, gribozavr Reviewed By: alexfh Subscribers: dkrupp, whisperity, rnkovacs, mgrang, cfe-commits Patch by Tibor Brunner! Tags: #clang Differential Revision: https://reviews.llvm.org/D65065 llvm-svn: 369763
-rw-r--r--clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp5
-rw-r--r--clang-tools-extra/test/clang-tidy/duplicate-reports.cpp15
2 files changed, 18 insertions, 2 deletions
diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index 1074af97786..ef1c8ef486e 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -742,8 +742,9 @@ struct LessClangTidyError {
const tooling::DiagnosticMessage &M1 = LHS.Message;
const tooling::DiagnosticMessage &M2 = RHS.Message;
- return std::tie(M1.FilePath, M1.FileOffset, M1.Message) <
- std::tie(M2.FilePath, M2.FileOffset, M2.Message);
+ return
+ std::tie(M1.FilePath, M1.FileOffset, LHS.DiagnosticName, M1.Message) <
+ std::tie(M2.FilePath, M2.FileOffset, RHS.DiagnosticName, M2.Message);
}
};
struct EqualClangTidyError {
diff --git a/clang-tools-extra/test/clang-tidy/duplicate-reports.cpp b/clang-tools-extra/test/clang-tidy/duplicate-reports.cpp
new file mode 100644
index 00000000000..c825c2ca243
--- /dev/null
+++ b/clang-tools-extra/test/clang-tidy/duplicate-reports.cpp
@@ -0,0 +1,15 @@
+// RUN: %check_clang_tidy %s cert-err09-cpp,cert-err61-cpp %t
+
+void alwaysThrows() {
+ int ex = 42;
+ // CHECK-MESSAGES: warning: throw expression should throw anonymous temporary values instead [cert-err09-cpp]
+ // CHECK-MESSAGES: warning: throw expression should throw anonymous temporary values instead [cert-err61-cpp]
+ throw ex;
+}
+
+void doTheJob() {
+ try {
+ alwaysThrows();
+ } catch (int&) {
+ }
+}
OpenPOWER on IntegriCloud