diff options
author | Chad Rosier <mcrosier@apple.com> | 2012-02-24 02:06:33 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@apple.com> | 2012-02-24 02:06:33 +0000 |
commit | 68fbb3ee8ae374b6505885e907af92b30eef707f (patch) | |
tree | e3ae9836686bf13f5050a7b3256b4b79bb94e374 /lib/StaticAnalyzer/Core/BugReporterVisitors.cpp | |
parent | 8cceefac395d476114b3d4ecd7e969b2e1c9271d (diff) |
Revert r151317 - Rework PathDiagnostics creation.. - to appease buildbots.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151338 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/BugReporterVisitors.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Core/BugReporterVisitors.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp index 2980190945..4b290626c0 100644 --- a/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp +++ b/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp @@ -709,3 +709,51 @@ ConditionBRVisitor::VisitTrueTest(const Expr *Cond, return new PathDiagnosticEventPiece(Loc, Out.str()); } +static PathDiagnosticLocation getLastStmtLoc(const ExplodedNode *N, + const SourceManager &SM) { + while (N) { + ProgramPoint PP = N->getLocation(); + if (const StmtPoint *SP = dyn_cast<StmtPoint>(&PP)) + return PathDiagnosticLocation(SP->getStmt(), SM, PP.getLocationContext()); + if (N->pred_empty()) + break; + N = *N->pred_begin(); + } + return PathDiagnosticLocation(); +} + +PathDiagnosticPiece * +CallEnterExitBRVisitor::VisitNode(const ExplodedNode *N, + const ExplodedNode *PrevN, + BugReporterContext &BRC, + BugReport &BR) { + ProgramPoint PP = N->getLocation(); + SmallString<256> buf; + llvm::raw_svector_ostream Out(buf); + PathDiagnosticLocation pos; + + if (const CallEnter *CEnter = dyn_cast<CallEnter>(&PP)) { + const Decl *callee = CEnter->getCalleeContext()->getDecl(); + pos = PathDiagnosticLocation(CEnter->getCallExpr(), BRC.getSourceManager(), + PP.getLocationContext()); + if (isa<BlockDecl>(callee)) + Out << "Entering call to block"; + else if (const NamedDecl *ND = dyn_cast<NamedDecl>(callee)) + Out << "Entering call to '" << *ND << "'"; + StringRef msg = Out.str(); + if (msg.empty()) + return 0; + return new PathDiagnosticCallEnterPiece(pos, msg); + } + else if (const CallExit *CExit = dyn_cast<CallExit>(&PP)) { + const Decl *caller = CExit->getLocationContext()->getParent()->getDecl(); + pos = getLastStmtLoc(PrevN, BRC.getSourceManager()); + if (const NamedDecl *ND = dyn_cast<NamedDecl>(caller)) + Out << "Returning to '" << *ND << "'"; + else + Out << "Returning to caller"; + return new PathDiagnosticCallExitPiece(pos, Out.str()); + } + + return 0; +} |