]> granicus.if.org Git - clang/commitdiff
PathDiagnosticLocation: ranges for terminators now only include the first
authorTed Kremenek <kremenek@apple.com>
Wed, 22 Apr 2009 18:03:00 +0000 (18:03 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 22 Apr 2009 18:03:00 +0000 (18:03 +0000)
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

lib/Analysis/PathDiagnostic.cpp

index 1d00727d0a2acee2bf1e0065a31f02a3bf7b296a..fa075a395955841cf96135c5f8ec7cb4686c88ac 100644 (file)
@@ -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();