diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-03-28 04:08:14 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-03-28 04:08:14 +0000 |
commit | cd58cced81ad3e7053d15a2caaa5442dcdcdda21 (patch) | |
tree | 6b72482db3a9513a9b25f78d3520722daf9e7123 /clang/lib/Analysis/BugReporter.cpp | |
parent | 1894f0d4993068de0f06680236b9f7ddd04210bc (diff) | |
download | bcm5719-llvm-cd58cced81ad3e7053d15a2caaa5442dcdcdda21.tar.gz bcm5719-llvm-cd58cced81ad3e7053d15a2caaa5442dcdcdda21.zip |
Text PathDiagnosticBuilder::getEnclosingStmt() about '?'
llvm-svn: 67909
Diffstat (limited to 'clang/lib/Analysis/BugReporter.cpp')
-rw-r--r-- | clang/lib/Analysis/BugReporter.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/clang/lib/Analysis/BugReporter.cpp b/clang/lib/Analysis/BugReporter.cpp index be666706414..01a74ced223 100644 --- a/clang/lib/Analysis/BugReporter.cpp +++ b/clang/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; |