aboutsummaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer/Core/BugReporter.cpp
diff options
context:
space:
mode:
authorChad Rosier <mcrosier@apple.com>2012-02-24 02:06:33 +0000
committerChad Rosier <mcrosier@apple.com>2012-02-24 02:06:33 +0000
commit68fbb3ee8ae374b6505885e907af92b30eef707f (patch)
treee3ae9836686bf13f5050a7b3256b4b79bb94e374 /lib/StaticAnalyzer/Core/BugReporter.cpp
parent8cceefac395d476114b3d4ecd7e969b2e1c9271d (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/BugReporter.cpp')
-rw-r--r--lib/StaticAnalyzer/Core/BugReporter.cpp111
1 files changed, 32 insertions, 79 deletions
diff --git a/lib/StaticAnalyzer/Core/BugReporter.cpp b/lib/StaticAnalyzer/Core/BugReporter.cpp
index 0c91164045..0dbc7f115d 100644
--- a/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -447,7 +447,7 @@ public:
PathDiagnosticLocation L =
PathDiagnosticLocation::createBegin(S, BR.getSourceManager(),
Pred->getLocationContext());
- PD.getActivePath().push_front(new PathDiagnosticEventPiece(L, os.str()));
+ PD.path.push_front(new PathDiagnosticEventPiece(L, os.str()));
}
return true;
@@ -529,32 +529,6 @@ static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD,
NextNode = GetPredecessorNode(N);
ProgramPoint P = N->getLocation();
-
- if (const CallExit *CE = dyn_cast<CallExit>(&P)) {
- PathDiagnosticCallPiece *C =
- PathDiagnosticCallPiece::construct(N, *CE, SMgr);
- PD.getActivePath().push_front(C);
- PD.pushActivePath(&C->path);
- continue;
- }
-
- if (const CallEnter *CE = dyn_cast<CallEnter>(&P)) {
- PD.popActivePath();
- // The current active path should never be empty. Either we
- // just added a bunch of stuff to the top-level path, or
- // we have a previous CallExit. If the front of the active
- // path is not a PathDiagnosticCallPiece, it means that the
- // path terminated within a function call. We must then take the
- // current contents of the active path and place it within
- // a new PathDiagnosticCallPiece.
- assert(!PD.getActivePath().empty());
- PathDiagnosticCallPiece *C =
- dyn_cast<PathDiagnosticCallPiece>(PD.getActivePath().front());
- if (!C)
- C = PathDiagnosticCallPiece::construct(PD.getActivePath());
- C->setCallee(*CE, SMgr);
- continue;
- }
if (const BlockEdge *BE = dyn_cast<BlockEdge>(&P)) {
const CFGBlock *Src = BE->getSrc();
@@ -585,7 +559,7 @@ static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD,
os << "Control jumps to line "
<< End.asLocation().getExpansionLineNumber();
- PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(Start, End,
+ PD.path.push_front(new PathDiagnosticControlFlowPiece(Start, End,
os.str()));
break;
}
@@ -637,13 +611,13 @@ static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD,
break;
}
}
- PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(Start, End,
+ PD.path.push_front(new PathDiagnosticControlFlowPiece(Start, End,
os.str()));
}
else {
os << "'Default' branch taken. ";
const PathDiagnosticLocation &End = PDB.ExecutionContinues(os, N);
- PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(Start, End,
+ PD.path.push_front(new PathDiagnosticControlFlowPiece(Start, End,
os.str()));
}
@@ -655,7 +629,7 @@ static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD,
std::string sbuf;
llvm::raw_string_ostream os(sbuf);
PathDiagnosticLocation End = PDB.ExecutionContinues(os, N);
- PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(Start, End,
+ PD.path.push_front(new PathDiagnosticControlFlowPiece(Start, End,
os.str()));
break;
}
@@ -677,7 +651,7 @@ static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD,
if (const Stmt *S = End.asStmt())
End = PDB.getEnclosingStmtLocation(S);
- PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(Start, End,
+ PD.path.push_front(new PathDiagnosticControlFlowPiece(Start, End,
os.str()));
break;
}
@@ -700,14 +674,14 @@ static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD,
PathDiagnosticLocation End(B->getLHS(), SMgr, LC);
PathDiagnosticLocation Start =
PathDiagnosticLocation::createOperatorLoc(B, SMgr);
- PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(Start, End,
+ PD.path.push_front(new PathDiagnosticControlFlowPiece(Start, End,
os.str()));
}
else {
os << "true";
PathDiagnosticLocation Start(B->getLHS(), SMgr, LC);
PathDiagnosticLocation End = PDB.ExecutionContinues(N);
- PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(Start, End,
+ PD.path.push_front(new PathDiagnosticControlFlowPiece(Start, End,
os.str()));
}
}
@@ -719,7 +693,7 @@ static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD,
os << "false";
PathDiagnosticLocation Start(B->getLHS(), SMgr, LC);
PathDiagnosticLocation End = PDB.ExecutionContinues(N);
- PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(Start, End,
+ PD.path.push_front(new PathDiagnosticControlFlowPiece(Start, End,
os.str()));
}
else {
@@ -727,7 +701,7 @@ static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD,
PathDiagnosticLocation End(B->getLHS(), SMgr, LC);
PathDiagnosticLocation Start =
PathDiagnosticLocation::createOperatorLoc(B, SMgr);
- PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(Start, End,
+ PD.path.push_front(new PathDiagnosticControlFlowPiece(Start, End,
os.str()));
}
}
@@ -746,7 +720,7 @@ static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD,
if (const Stmt *S = End.asStmt())
End = PDB.getEnclosingStmtLocation(S);
- PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(Start, End,
+ PD.path.push_front(new PathDiagnosticControlFlowPiece(Start, End,
os.str()));
}
else {
@@ -755,7 +729,7 @@ static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD,
if (const Stmt *S = End.asStmt())
End = PDB.getEnclosingStmtLocation(S);
- PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(Start, End,
+ PD.path.push_front(new PathDiagnosticControlFlowPiece(Start, End,
"Loop condition is false. Exiting loop"));
}
@@ -773,7 +747,7 @@ static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD,
if (const Stmt *S = End.asStmt())
End = PDB.getEnclosingStmtLocation(S);
- PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(Start, End,
+ PD.path.push_front(new PathDiagnosticControlFlowPiece(Start, End,
os.str()));
}
else {
@@ -781,7 +755,7 @@ static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD,
if (const Stmt *S = End.asStmt())
End = PDB.getEnclosingStmtLocation(S);
- PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(Start, End,
+ PD.path.push_front(new PathDiagnosticControlFlowPiece(Start, End,
"Loop condition is true. Entering loop body"));
}
@@ -795,10 +769,10 @@ static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD,
End = PDB.getEnclosingStmtLocation(S);
if (*(Src->succ_begin()+1) == Dst)
- PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(Start, End,
+ PD.path.push_front(new PathDiagnosticControlFlowPiece(Start, End,
"Taking false branch"));
else
- PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(Start, End,
+ PD.path.push_front(new PathDiagnosticControlFlowPiece(Start, End,
"Taking true branch"));
break;
@@ -812,7 +786,7 @@ static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD,
for (BugReport::visitor_iterator I = R->visitor_begin(),
E = R->visitor_end(); I!=E; ++I) {
if (PathDiagnosticPiece *p = (*I)->VisitNode(N, NextNode, PDB, *R))
- PD.getActivePath().push_front(p);
+ PD.path.push_front(p);
}
}
@@ -1045,7 +1019,7 @@ void EdgeBuilder::rawAddEdge(PathDiagnosticLocation NewLoc) {
PrevLocClean.asLocation().getExpansionLoc())
return;
- PD.getActivePath().push_front(new PathDiagnosticControlFlowPiece(NewLocClean, PrevLocClean));
+ PD.path.push_front(new PathDiagnosticControlFlowPiece(NewLocClean, PrevLocClean));
PrevLoc = NewLoc;
}
@@ -1172,10 +1146,6 @@ static void GenerateExtensivePathDiagnostic(PathDiagnostic& PD,
LCtx);
EB.addEdge(Loc, true);
EB.flushLocations();
- PathDiagnosticCallPiece *C =
- PathDiagnosticCallPiece::construct(N, *CE, SM);
- PD.getActivePath().push_front(C);
- PD.pushActivePath(&C->path);
break;
}
@@ -1186,27 +1156,6 @@ static void GenerateExtensivePathDiagnostic(PathDiagnostic& PD,
N->getLocationContext()->getCurrentStackFrame()) {
EB.flushLocations();
}
-
- // Pop the call hierarchy if we are done walking the contents
- // of a function call.
- if (const CallEnter *CE = dyn_cast<CallEnter>(&P)) {
- PD.popActivePath();
- // The current active path should never be empty. Either we
- // just added a bunch of stuff to the top-level path, or
- // we have a previous CallExit. If the front of the active
- // path is not a PathDiagnosticCallPiece, it means that the
- // path terminated within a function call. We must then take the
- // current contents of the active path and place it within
- // a new PathDiagnosticCallPiece.
- assert(!PD.getActivePath().empty());
- PathDiagnosticCallPiece *C =
- dyn_cast<PathDiagnosticCallPiece>(PD.getActivePath().front());
- if (!C)
- C = PathDiagnosticCallPiece::construct(PD.getActivePath());
- C->setCallee(*CE, SM);
- EB.addContext(CE->getCallExpr());
- break;
- }
// Block edges.
if (const BlockEdge *BE = dyn_cast<BlockEdge>(&P)) {
@@ -1230,7 +1179,7 @@ static void GenerateExtensivePathDiagnostic(PathDiagnostic& PD,
"Looping back to the head of the loop");
EB.addEdge(p->getLocation(), true);
- PD.getActivePath().push_front(p);
+ PD.path.push_front(p);
if (CS) {
PathDiagnosticLocation BL =
@@ -1272,7 +1221,7 @@ static void GenerateExtensivePathDiagnostic(PathDiagnostic& PD,
if (PathDiagnosticPiece *p = (*I)->VisitNode(N, NextNode, PDB, *R)) {
const PathDiagnosticLocation &Loc = p->getLocation();
EB.addEdge(Loc, true);
- PD.getActivePath().push_front(p);
+ PD.path.push_front(p);
if (const Stmt *S = Loc.asStmt())
EB.addExtendedContext(PDB.getEnclosingStmtLocation(S).asStmt());
}
@@ -1603,8 +1552,8 @@ MakeReportGraph(const ExplodedGraph* G,
/// CompactPathDiagnostic - This function postprocesses a PathDiagnostic object
/// and collapses PathDiagosticPieces that are expanded by macros.
static void CompactPathDiagnostic(PathDiagnostic &PD, const SourceManager& SM) {
- typedef std::vector<std::pair<IntrusiveRefCntPtr<PathDiagnosticMacroPiece>,
- SourceLocation> > MacroStackTy;
+ typedef std::vector<std::pair<IntrusiveRefCntPtr<PathDiagnosticMacroPiece>, SourceLocation> >
+ MacroStackTy;
typedef std::vector<IntrusiveRefCntPtr<PathDiagnosticPiece> >
PiecesTy;
@@ -1612,8 +1561,7 @@ static void CompactPathDiagnostic(PathDiagnostic &PD, const SourceManager& SM) {
MacroStackTy MacroStack;
PiecesTy Pieces;
- for (PathPieces::const_iterator I = PD.path.begin(), E = PD.path.end();
- I!=E; ++I) {
+ for (PathPieces::iterator I = PD.path.begin(), E = PD.path.end(); I!=E; ++I) {
// Get the location of the PathDiagnosticPiece.
const FullSourceLoc Loc = (*I)->getLocation().asLocation();
@@ -1682,13 +1630,13 @@ static void CompactPathDiagnostic(PathDiagnostic &PD, const SourceManager& SM) {
}
// Now take the pieces and construct a new PathDiagnostic.
- PD.getMutablePieces().clear();
+ PD.path.clear();
for (PiecesTy::iterator I=Pieces.begin(), E=Pieces.end(); I!=E; ++I) {
if (PathDiagnosticMacroPiece *MP = dyn_cast<PathDiagnosticMacroPiece>(*I))
if (!MP->containsEvent())
continue;
- PD.getMutablePieces().push_back(*I);
+ PD.path.push_back(*I);
}
}
@@ -1724,6 +1672,11 @@ void GRBugReporter::GeneratePathDiagnostic(PathDiagnostic& PD,
// Register additional node visitors.
R->addVisitor(new NilReceiverBRVisitor());
R->addVisitor(new ConditionBRVisitor());
+
+ // If inlining is turning out, emit diagnostics for CallEnter and
+ // CallExit at the top level.
+ bool showTopLevel = Eng.getAnalysisManager().shouldInlineCall();
+ R->addVisitor(new CallEnterExitBRVisitor(showTopLevel));
// Generate the very last diagnostic piece - the piece is visible before
// the trace is expanded.
@@ -1739,7 +1692,7 @@ void GRBugReporter::GeneratePathDiagnostic(PathDiagnostic& PD,
if (!LastPiece)
LastPiece = BugReporterVisitor::getDefaultEndPath(PDB, N, *R);
if (LastPiece)
- PD.getActivePath().push_back(LastPiece);
+ PD.path.push_back(LastPiece);
else
return;
@@ -2004,7 +1957,7 @@ void BugReporter::FlushReport(BugReportEquivClass& EQ) {
exampleReport->getDescription());
for ( ; Beg != End; ++Beg) piece->addRange(*Beg);
- D->getActivePath().push_back(piece);
+ D->path.push_back(piece);
}
PD->HandlePathDiagnostic(D.take());