aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-04-22 18:03:00 +0000
committerTed Kremenek <kremenek@apple.com>2009-04-22 18:03:00 +0000
commit8f33290741c2c6190576523e06a0d3bb698554b1 (patch)
tree4d99bb23c785e9b233e7e5e58bdf9b976013ca3b
parenta80a0f6398df06c018af779a7ca82a29172c45d1 (diff)
PathDiagnosticLocation: ranges for terminators now only include the first
character instead of the entire range for the IfStmt, ForStmt, etc. We may gradually refine these ranges later, but basically terminator ranges just refer to the first keyword. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69812 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Analysis/PathDiagnostic.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/lib/Analysis/PathDiagnostic.cpp b/lib/Analysis/PathDiagnostic.cpp
index 1d00727d0a..fa075a3959 100644
--- a/lib/Analysis/PathDiagnostic.cpp
+++ b/lib/Analysis/PathDiagnostic.cpp
@@ -166,8 +166,29 @@ SourceRange PathDiagnosticLocation::asRange() const {
case SingleLocK:
case RangeK:
break;
- case StmtK:
+ case StmtK: {
+ const Stmt *S = asStmt();
+ switch (S->getStmtClass()) {
+ default:
+ break;
+ // FIXME: Provide better range information for different
+ // terminators.
+ case Stmt::IfStmtClass:
+ case Stmt::WhileStmtClass:
+ case Stmt::DoStmtClass:
+ case Stmt::ForStmtClass:
+ case Stmt::ChooseExprClass:
+ case Stmt::IndirectGotoStmtClass:
+ case Stmt::SwitchStmtClass:
+ case Stmt::ConditionalOperatorClass:
+ case Stmt::ObjCForCollectionStmtClass: {
+ SourceLocation L = S->getLocStart();
+ return SourceRange(L, L);
+ }
+ }
+
return S->getSourceRange();
+ }
case DeclK:
if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D))
return MD->getSourceRange();