aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/BugReporter.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-05-06 18:11:09 +0000
committerTed Kremenek <kremenek@apple.com>2008-05-06 18:11:09 +0000
commit143ca222583a4a355fdc89af852deef287499300 (patch)
tree876ba4fd37cb984f262759ea202dccc9a7b56993 /lib/Analysis/BugReporter.cpp
parent5251e130a23d997f7c0dfdc250cdc41f179e5bed (diff)
More refactorings in GeneratePathDiagnostic: use ExecutionContinues to display
"Execution continues..." message, which does a better job at handling corner cases. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50751 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/BugReporter.cpp')
-rw-r--r--lib/Analysis/BugReporter.cpp42
1 files changed, 28 insertions, 14 deletions
diff --git a/lib/Analysis/BugReporter.cpp b/lib/Analysis/BugReporter.cpp
index c907c248c0..e2d98b0cf6 100644
--- a/lib/Analysis/BugReporter.cpp
+++ b/lib/Analysis/BugReporter.cpp
@@ -48,10 +48,8 @@ static inline Stmt* GetStmt(const ProgramPoint& P) {
}
static inline Stmt* GetStmt(const CFGBlock* B) {
- if (B->empty()) {
- assert (B->getTerminator() && "Empty block should have a terminator.");
+ if (B->empty())
return const_cast<Stmt*>(B->getTerminator());
- }
else
return (*B)[0];
}
@@ -75,19 +73,35 @@ static Stmt* GetLastStmt(ExplodedNode<ValueState>* N) {
return NULL;
}
-
-static void ExecutionContinues(std::ostream& os, SourceManager& SMgr,
- ExplodedNode<ValueState>* N) {
-
- Stmt* S = GetStmt(N->getLocation());
+static void ExecutionContinues(std::ostringstream& os, SourceManager& SMgr,
+ Stmt* S) {
if (!S)
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()) << '.';
}
+
+
+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 {
@@ -375,8 +389,8 @@ void BugReporter::GeneratePathDiagnostic(PathDiagnostic& PD,
std::ostringstream os;
- os << "Loop condition is true. Execution continues on line "
- << SMgr.getLogicalLineNumber(GetStmt(Dst)->getLocStart()) << '.';
+ os << "Loop condition is true.";
+ ExecutionContinues(os, SMgr, Dst);
PD.push_front(new PathDiagnosticPiece(L, os.str()));
}
@@ -394,8 +408,8 @@ void BugReporter::GeneratePathDiagnostic(PathDiagnostic& PD,
std::ostringstream os;
- os << "Loop condition is false. Execution continues on line "
- << SMgr.getLogicalLineNumber(GetStmt(Dst)->getLocStart()) << '.';
+ os << "Loop condition is false.";
+ ExecutionContinues(os, SMgr, Dst);
PD.push_front(new PathDiagnosticPiece(L, os.str()));
}