]> granicus.if.org Git - clang/commitdiff
PathDiagnosticLocation::asRange(): for a PathDiagnosticLocation, the range of a DeclS...
authorTed Kremenek <kremenek@apple.com>
Fri, 15 May 2009 02:05:25 +0000 (02:05 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 15 May 2009 02:05:25 +0000 (02:05 +0000)
the decl + initializer.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71831 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/PathDiagnostic.cpp

index 1a4af471f5c98045e4b6c4045af683963f1e5959..ec96329852d487402f6c7135aa202f54c127067c 100644 (file)
@@ -173,6 +173,15 @@ PathDiagnosticRange PathDiagnosticLocation::asRange() const {
       switch (S->getStmtClass()) {
         default:
           break;
+        case Stmt::DeclStmtClass: {
+          const DeclStmt *DS = cast<DeclStmt>(S);
+          if (DS->isSingleDecl()) {
+            // Should always be the case, but we'll be defensive.
+            return SourceRange(DS->getLocStart(),
+                               DS->getSingleDecl()->getLocation());            
+          }
+          break;
+        }
           // FIXME: Provide better range information for different
           //  terminators.
         case Stmt::IfStmtClass: