Skip to content

Commit

Permalink
[Analyzer] Remove inclusion of uniqueing decl from diagnostic profile.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
balazske committed Jul 30, 2020
1 parent 23ad660 commit 1745ba4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 0 additions & 1 deletion clang/lib/Analysis/PathDiagnostic.cpp
Expand Up @@ -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);
Expand Down
16 changes: 16 additions & 0 deletions 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
// different 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);
}

0 comments on commit 1745ba4

Please sign in to comment.