[cfe-commits] r67909 - /cfe/trunk/lib/Analysis/BugReporter.cpp
Ted Kremenek
kremenek at apple.com
Fri Mar 27 21:08:14 PDT 2009
Author: kremenek
Date: Fri Mar 27 23:08:14 2009
New Revision: 67909
URL: http://llvm.org/viewvc/llvm-project?rev=67909&view=rev
Log:
Text PathDiagnosticBuilder::getEnclosingStmt() about '?'
Modified:
cfe/trunk/lib/Analysis/BugReporter.cpp
Modified: cfe/trunk/lib/Analysis/BugReporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BugReporter.cpp?rev=67909&r1=67908&r2=67909&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/BugReporter.cpp (original)
+++ cfe/trunk/lib/Analysis/BugReporter.cpp Fri Mar 27 23:08:14 2009
@@ -157,7 +157,21 @@
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 @@
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 @@
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;
More information about the cfe-commits
mailing list