diff options
author | Anna Zaks <ganna@apple.com> | 2012-03-14 18:58:28 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2012-03-14 18:58:28 +0000 |
commit | 9373937945e1e075dfa08169eaccc1ad0b31f699 (patch) | |
tree | d3cb5d84862683acf1a1df1f9b9c4efe27f40318 /lib/StaticAnalyzer/Core | |
parent | de5d946288bb3d68576c95974beb8cfd21d7043a (diff) |
[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
Diffstat (limited to 'lib/StaticAnalyzer/Core')
-rw-r--r-- | lib/StaticAnalyzer/Core/BugReporter.cpp | 12 | ||||
-rw-r--r-- | lib/StaticAnalyzer/Core/PathDiagnostic.cpp | 7 |
2 files changed, 12 insertions, 7 deletions
diff --git a/lib/StaticAnalyzer/Core/BugReporter.cpp b/lib/StaticAnalyzer/Core/BugReporter.cpp index 4ada636e8e..995ef264eb 100644 --- a/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/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/lib/StaticAnalyzer/Core/PathDiagnostic.cpp b/lib/StaticAnalyzer/Core/PathDiagnostic.cpp index d09bb3280b..ef815be0db 100644 --- a/lib/StaticAnalyzer/Core/PathDiagnostic.cpp +++ b/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); |