]> granicus.if.org Git - clang/commitdiff
Implement PathDiagnosticLocation::asRange() and PathDiagnosticLocation::asStmt().
authorTed Kremenek <kremenek@apple.com>
Thu, 26 Mar 2009 21:48:17 +0000 (21:48 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 26 Mar 2009 21:48:17 +0000 (21:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67777 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/PathDiagnostic.h
lib/Analysis/PathDiagnostic.cpp

index f647be9d6dc97dfc75f8e897d3e031184de6d693..1481e25bbdb0baa8adb644bbe920e8db07d7a545 100644 (file)
@@ -67,7 +67,7 @@ public:
     
   FullSourceLoc asLocation() const;
   SourceRange asRange() const;
-  const Stmt *asStmt() const;
+  const Stmt *asStmt() const { return S ? S : 0; }
 };
 
 class PathDiagnostic {
index 1441088e547e90ed1e7f590068a52cb280bb47d9..dd9a0a8f46055b90268d24207586b1177f7edee4 100644 (file)
@@ -152,3 +152,18 @@ FullSourceLoc PathDiagnosticLocation::asLocation() const {
   
   return FullSourceLoc(R.getBegin(), const_cast<SourceManager&>(SM));
 }
+
+SourceRange PathDiagnosticLocation::asRange() const {
+  // Note that we want a 'switch' here so that the compiler can warn us in
+  // case we add more cases.
+  switch (K) {
+    case SingleLoc:
+    case Range:
+      break;
+    case Statement:
+      return S->getSourceRange();
+  }
+  
+  return R;
+}
+