[cfe-commits] r69834 - in /cfe/trunk: include/clang/Analysis/PathDiagnostic.h lib/Analysis/PathDiagnostic.cpp lib/Frontend/PlistDiagnostics.cpp

Ted Kremenek kremenek at apple.com
Wed Apr 22 15:26:15 PDT 2009


Author: kremenek
Date: Wed Apr 22 17:26:10 2009
New Revision: 69834

URL: http://llvm.org/viewvc/llvm-project?rev=69834&view=rev
Log:
Add PathDiagnosticRange to PathDiagnostics. These simply wrap SourceRange and
indicate whether or not the range represents an absolute range or should be
extended by lexing to the end of the token.

Modified:
    cfe/trunk/include/clang/Analysis/PathDiagnostic.h
    cfe/trunk/lib/Analysis/PathDiagnostic.cpp
    cfe/trunk/lib/Frontend/PlistDiagnostics.cpp

Modified: cfe/trunk/include/clang/Analysis/PathDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathDiagnostic.h?rev=69834&r1=69833&r2=69834&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathDiagnostic.h (original)
+++ cfe/trunk/include/clang/Analysis/PathDiagnostic.h Wed Apr 22 17:26:10 2009
@@ -55,6 +55,14 @@
 //===----------------------------------------------------------------------===//
 // 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 @@
   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; }
   

Modified: cfe/trunk/lib/Analysis/PathDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/PathDiagnostic.cpp?rev=69834&r1=69833&r2=69834&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/PathDiagnostic.cpp (original)
+++ cfe/trunk/lib/Analysis/PathDiagnostic.cpp Wed Apr 22 17:26:10 2009
@@ -158,12 +158,13 @@
   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 @@
       }
       else {
         SourceLocation L = D->getLocation();
-        return SourceRange(L, L);
+        return PathDiagnosticRange(SourceRange(L, L), true);
       }
   }
   

Modified: cfe/trunk/lib/Frontend/PlistDiagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PlistDiagnostics.cpp?rev=69834&r1=69833&r2=69834&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/PlistDiagnostics.cpp (original)
+++ cfe/trunk/lib/Frontend/PlistDiagnostics.cpp Wed Apr 22 17:26:10 2009
@@ -111,11 +111,11 @@
 
 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";
 }
 





More information about the cfe-commits mailing list