]> granicus.if.org Git - clang/commitdiff
Add PathDiagnosticRange to PathDiagnostics. These simply wrap SourceRange and
authorTed Kremenek <kremenek@apple.com>
Wed, 22 Apr 2009 22:26:10 +0000 (22:26 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 22 Apr 2009 22:26:10 +0000 (22:26 +0000)
indicate whether or not the range represents an absolute range or should be
extended by lexing to the end of the token.

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

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

index 0e0b85eb109de4dc3f5c6e676ed86d3f5d074388..84fe8d92c60d379a1a6ae6f48b8076ddacaedada 100644 (file)
@@ -55,6 +55,14 @@ public:
 //===----------------------------------------------------------------------===//
 // Path-sensitive diagnostics.
 //===----------------------------------------------------------------------===//
+
+class PathDiagnosticRange : public SourceRange {
+public:
+  const bool isPoint;
+  
+  PathDiagnosticRange(const SourceRange &R, bool isP = false)
+    : SourceRange(R), isPoint(isP) {}
+};
   
 class PathDiagnosticLocation {
 private:
@@ -103,7 +111,7 @@ public:
   const SourceManager& getSourceManager() const { assert(isValid());return *SM;}
     
   FullSourceLoc asLocation() const;
-  SourceRange asRange() const;
+  PathDiagnosticRange asRange() const;
   const Stmt *asStmt() const { assert(isValid()); return S; }
   const Decl *asDecl() const { assert(isValid()); return D; }
   
index fa075a395955841cf96135c5f8ec7cb4686c88ac..946548e02cc276382c46ed4ed8b946e18d45f945 100644 (file)
@@ -158,12 +158,13 @@ FullSourceLoc PathDiagnosticLocation::asLocation() const {
   return FullSourceLoc(R.getBegin(), const_cast<SourceManager&>(*SM));
 }
 
-SourceRange PathDiagnosticLocation::asRange() const {
+PathDiagnosticRange PathDiagnosticLocation::asRange() const {
   assert(isValid());
   // Note that we want a 'switch' here so that the compiler can warn us in
   // case we add more cases.
   switch (K) {
     case SingleLocK:
+      return PathDiagnosticRange(R, true);
     case RangeK:
       break;
     case StmtK: {
@@ -201,7 +202,7 @@ SourceRange PathDiagnosticLocation::asRange() const {
       }
       else {
         SourceLocation L = D->getLocation();
-        return SourceRange(L, L);
+        return PathDiagnosticRange(SourceRange(L, L), true);
       }
   }
   
index d67740aa9d66c8a41c369152e03e0a524d6f0237..7ad900e8741ccd72be7fc2db71e3b7836e4b8fb4 100644 (file)
@@ -111,11 +111,11 @@ static void EmitLocation(llvm::raw_ostream& o, const SourceManager &SM,
 
 static void EmitRange(llvm::raw_ostream& o, const SourceManager &SM,
                       const LangOptions &LangOpts,
-                      SourceRange R, const FIDMap &FM,
+                      PathDiagnosticRange R, const FIDMap &FM,
                       unsigned indent) {
   Indent(o, indent) << "<array>\n";
   EmitLocation(o, SM, LangOpts, R.getBegin(), FM, indent+1);  
-  EmitLocation(o, SM, LangOpts, R.getEnd(), FM, indent+1, true);
+  EmitLocation(o, SM, LangOpts, R.getEnd(), FM, indent+1, !R.isPoint);
   Indent(o, indent) << "</array>\n";
 }