summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2012-03-14 18:58:28 +0000
committerAnna Zaks <ganna@apple.com>2012-03-14 18:58:28 +0000
commitd4e9059fe0af95c0b0ef75f99e8c1a5b005c3ca2 (patch)
tree2da0a00914c956a88f05450083588d8a7666c0e5 /clang/lib
parenta88fdd3cddb4eb9d0e3d783eb06ebdbd7d311b65 (diff)
downloadbcm5719-llvm-d4e9059fe0af95c0b0ef75f99e8c1a5b005c3ca2.tar.gz
bcm5719-llvm-d4e9059fe0af95c0b0ef75f99e8c1a5b005c3ca2.zip
[analyzer] Diagnostics: Supply Caller information even if the bug occurs
in the callee. llvm-svn: 152734
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/StaticAnalyzer/Core/BugReporter.cpp12
-rw-r--r--clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp7
2 files changed, 12 insertions, 7 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
index 4ada636e8e9..995ef264eb4 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -418,8 +418,10 @@ static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD,
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 @@ static void GenerateExtensivePathDiagnostic(PathDiagnostic& PD,
// 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;
diff --git a/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp b/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
index d09bb3280bb..ef815be0dbb 100644
--- a/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ b/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -515,8 +515,9 @@ PathDiagnosticCallPiece::construct(const ExplodedNode *N,
}
PathDiagnosticCallPiece *
-PathDiagnosticCallPiece::construct(PathPieces &path) {
- PathDiagnosticCallPiece *C = new PathDiagnosticCallPiece(path);
+PathDiagnosticCallPiece::construct(PathPieces &path,
+ const Decl *caller) {
+ PathDiagnosticCallPiece *C = new PathDiagnosticCallPiece(path, caller);
path.clear();
path.push_front(C);
return C;
@@ -563,7 +564,7 @@ PathDiagnosticCallPiece::getCallEnterWithinCallerEvent() const {
IntrusiveRefCntPtr<PathDiagnosticEventPiece>
PathDiagnosticCallPiece::getCallExitEvent() const {
- if (!Caller)
+ if (NoExit)
return 0;
SmallString<256> buf;
llvm::raw_svector_ostream Out(buf);
OpenPOWER on IntegriCloud