Author: Balázs Kéri Date: 2020-07-30T09:52:28+02:00 New Revision: 1745ba41b196d80d8a6739dffcbb6f613d371f29
URL: https://github.com/llvm/llvm-project/commit/1745ba41b196d80d8a6739dffcbb6f613d371f29 DIFF: https://github.com/llvm/llvm-project/commit/1745ba41b196d80d8a6739dffcbb6f613d371f29.diff LOG: [Analyzer] Remove inclusion of uniqueing decl from diagnostic profile. The uniqueing decl in PathDiagnostic is the declaration with the uniqueing loc, as stated by documentation comments. It is enough to include the uniqueing loc in the profile. It is possible to have objects with different uniqueing decl but same location, at least with templates. These belong to the same class and should have same profile. Reviewed By: vsavchenko, NoQ Differential Revision: https://reviews.llvm.org/D84843 Added: clang/test/Analysis/report-uniqueing.cpp Modified: clang/lib/Analysis/PathDiagnostic.cpp Removed: ################################################################################ diff --git a/clang/lib/Analysis/PathDiagnostic.cpp b/clang/lib/Analysis/PathDiagnostic.cpp index 9aa3386129d7..f80b99b99806 100644 --- a/clang/lib/Analysis/PathDiagnostic.cpp +++ b/clang/lib/Analysis/PathDiagnostic.cpp @@ -1134,7 +1134,6 @@ void PathDiagnosticPopUpPiece::Profile(llvm::FoldingSetNodeID &ID) const { void PathDiagnostic::Profile(llvm::FoldingSetNodeID &ID) const { ID.Add(getLocation()); ID.Add(getUniqueingLoc()); - ID.AddPointer(getUniqueingLoc().isValid() ? getUniqueingDecl() : nullptr); ID.AddString(BugType); ID.AddString(VerboseDesc); ID.AddString(Category); diff --git a/clang/test/Analysis/report-uniqueing.cpp b/clang/test/Analysis/report-uniqueing.cpp new file mode 100644 index 000000000000..0e4d50e13a20 --- /dev/null +++ b/clang/test/Analysis/report-uniqueing.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_analyze_cc1 -verify %s \ +// RUN: -analyzer-checker=security + +void bzero(void *, unsigned long); + +template <typename T> void foo(T l) { + // The warning comes from multiple instances and with + // diff erent declarations that have same source location. + // One instance should be shown. + bzero(l, 1); // expected-warning{{The bzero() function is obsoleted}} +} + +void p(int *p, unsigned *q) { + foo(p); + foo(q); +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits