[analyzer] Diagnostics: Supply Caller information even if the bug occurs
in the callee.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152734 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/StaticAnalyzer/Core/BugReporter.cpp b/lib/StaticAnalyzer/Core/BugReporter.cpp
index 4ada636..995ef26 100644
--- a/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -418,8 +418,10 @@
assert(!PD.getActivePath().empty());
PathDiagnosticCallPiece *C =
dyn_cast<PathDiagnosticCallPiece>(PD.getActivePath().front());
- if (!C)
- C = PathDiagnosticCallPiece::construct(PD.getActivePath());
+ if (!C) {
+ const Decl *Caller = CE->getLocationContext()->getDecl();
+ C = PathDiagnosticCallPiece::construct(PD.getActivePath(), Caller);
+ }
C->setCallee(*CE, SMgr);
continue;
}
@@ -1064,8 +1066,10 @@
// a new PathDiagnosticCallPiece.
PathDiagnosticCallPiece *C =
dyn_cast<PathDiagnosticCallPiece>(PD.getActivePath().front());
- if (!C)
- C = PathDiagnosticCallPiece::construct(PD.getActivePath());
+ if (!C) {
+ const Decl * Caller = CE->getLocationContext()->getDecl();
+ C = PathDiagnosticCallPiece::construct(PD.getActivePath(), Caller);
+ }
C->setCallee(*CE, SM);
EB.addContext(CE->getCallExpr());
break;