forked from OSchip/llvm-project
More refactorings in GeneratePathDiagnostic: use ExecutionContinues to display
"Execution continues..." message, which does a better job at handling corner cases. llvm-svn: 50751
This commit is contained in:
parent
fc905c64ab
commit
8bcc1bd3d5
|
|
@ -48,10 +48,8 @@ static inline Stmt* GetStmt(const ProgramPoint& P) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline Stmt* GetStmt(const CFGBlock* B) {
|
static inline Stmt* GetStmt(const CFGBlock* B) {
|
||||||
if (B->empty()) {
|
if (B->empty())
|
||||||
assert (B->getTerminator() && "Empty block should have a terminator.");
|
|
||||||
return const_cast<Stmt*>(B->getTerminator());
|
return const_cast<Stmt*>(B->getTerminator());
|
||||||
}
|
|
||||||
else
|
else
|
||||||
return (*B)[0];
|
return (*B)[0];
|
||||||
}
|
}
|
||||||
|
|
@ -75,19 +73,35 @@ static Stmt* GetLastStmt(ExplodedNode<ValueState>* N) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ExecutionContinues(std::ostringstream& os, SourceManager& SMgr,
|
||||||
static void ExecutionContinues(std::ostream& os, SourceManager& SMgr,
|
Stmt* S) {
|
||||||
ExplodedNode<ValueState>* N) {
|
|
||||||
|
|
||||||
Stmt* S = GetStmt(N->getLocation());
|
|
||||||
|
|
||||||
if (!S)
|
if (!S)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
os << "Execution continue on line "
|
// Slow, but probably doesn't matter.
|
||||||
|
if (os.str().empty())
|
||||||
|
os << ' ';
|
||||||
|
|
||||||
|
os << "Execution continues on line "
|
||||||
<< SMgr.getLogicalLineNumber(S->getLocStart()) << '.';
|
<< SMgr.getLogicalLineNumber(S->getLocStart()) << '.';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline void ExecutionContinues(std::ostringstream& os,
|
||||||
|
SourceManager& SMgr,
|
||||||
|
ExplodedNode<ValueState>* N) {
|
||||||
|
|
||||||
|
ExecutionContinues(os, SMgr, GetStmt(N->getLocation()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void ExecutionContinues(std::ostringstream& os,
|
||||||
|
SourceManager& SMgr,
|
||||||
|
const CFGBlock* B) {
|
||||||
|
|
||||||
|
ExecutionContinues(os, SMgr, GetStmt(B));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Stmt* BugReport::getStmt(BugReporter& BR) const {
|
Stmt* BugReport::getStmt(BugReporter& BR) const {
|
||||||
|
|
||||||
|
|
@ -375,8 +389,8 @@ void BugReporter::GeneratePathDiagnostic(PathDiagnostic& PD,
|
||||||
|
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
|
|
||||||
os << "Loop condition is true. Execution continues on line "
|
os << "Loop condition is true.";
|
||||||
<< SMgr.getLogicalLineNumber(GetStmt(Dst)->getLocStart()) << '.';
|
ExecutionContinues(os, SMgr, Dst);
|
||||||
|
|
||||||
PD.push_front(new PathDiagnosticPiece(L, os.str()));
|
PD.push_front(new PathDiagnosticPiece(L, os.str()));
|
||||||
}
|
}
|
||||||
|
|
@ -394,8 +408,8 @@ void BugReporter::GeneratePathDiagnostic(PathDiagnostic& PD,
|
||||||
|
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
|
|
||||||
os << "Loop condition is false. Execution continues on line "
|
os << "Loop condition is false.";
|
||||||
<< SMgr.getLogicalLineNumber(GetStmt(Dst)->getLocStart()) << '.';
|
ExecutionContinues(os, SMgr, Dst);
|
||||||
|
|
||||||
PD.push_front(new PathDiagnosticPiece(L, os.str()));
|
PD.push_front(new PathDiagnosticPiece(L, os.str()));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue