aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/BugReporter.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-03-28 04:08:14 +0000
committerTed Kremenek <kremenek@apple.com>2009-03-28 04:08:14 +0000
commit1d9a23ac34fee297e28361653a72c519cb04a854 (patch)
tree05772b70dc8f39fa4027a4cc875d572d7ff6eab3 /lib/Analysis/BugReporter.cpp
parentf67606ae2febe3bb0718f05040c6c4bc2c2c3276 (diff)
Text PathDiagnosticBuilder::getEnclosingStmt() about '?'
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67909 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/BugReporter.cpp')
-rw-r--r--lib/Analysis/BugReporter.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/Analysis/BugReporter.cpp b/lib/Analysis/BugReporter.cpp
index be66670641..01a74ced22 100644
--- a/lib/Analysis/BugReporter.cpp
+++ b/lib/Analysis/BugReporter.cpp
@@ -157,7 +157,21 @@ PathDiagnosticBuilder::getEnclosingStmtLocation(const Stmt *S) {
switch (Parent->getStmtClass()) {
case Stmt::CompoundStmtClass:
case Stmt::StmtExprClass:
- return PathDiagnosticLocation(S, SMgr);
+ return PathDiagnosticLocation(S, SMgr);
+ case Stmt::ChooseExprClass:
+ // Similar to '?' if we are referring to condition, just have the edge
+ // point to the entire choose expression.
+ if (cast<ChooseExpr>(Parent)->getCond() == S)
+ return PathDiagnosticLocation(Parent, SMgr);
+ else
+ return PathDiagnosticLocation(S, SMgr);
+ case Stmt::ConditionalOperatorClass:
+ // For '?', if we are referring to condition, just have the edge point
+ // to the entire '?' expression.
+ if (cast<ConditionalOperator>(Parent)->getCond() == S)
+ return PathDiagnosticLocation(Parent, SMgr);
+ else
+ return PathDiagnosticLocation(S, SMgr);
case Stmt::DoStmtClass:
if (cast<DoStmt>(Parent)->getCond() != S)
return PathDiagnosticLocation(S, SMgr);
@@ -914,7 +928,7 @@ void GRBugReporter::GeneratePathDiagnostic(PathDiagnostic& PD,
case Stmt::ConditionalOperatorClass: {
std::string sbuf;
llvm::raw_string_ostream os(sbuf);
- os << "'?' condition evaluates to ";
+ os << "'?' condition is ";
if (*(Src->succ_begin()+1) == Dst)
os << "false";
@@ -923,6 +937,9 @@ void GRBugReporter::GeneratePathDiagnostic(PathDiagnostic& PD,
PathDiagnosticLocation End = PDB.ExecutionContinues(N);
+ if (const Stmt *S = End.asStmt())
+ End = PDB.getEnclosingStmtLocation(S);
+
PD.push_front(new PathDiagnosticControlFlowPiece(Start, End,
os.str()));
break;