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

Ted Kremenek kremenek at apple.com
Thu Mar 26 14:39:40 PDT 2009


Author: kremenek
Date: Thu Mar 26 16:39:39 2009
New Revision: 67774

URL: http://llvm.org/viewvc/llvm-project?rev=67774&view=rev
Log:
- Implement PathDiagnosticLocation::asLocation.
- Switch PathDiagnosticEventPiece and PathDiagnosticMacroPiece to use
  PathDiagnosticLocation.

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

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

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathDiagnostic.h (original)
+++ cfe/trunk/include/clang/Analysis/PathDiagnostic.h Thu Mar 26 16:39:39 2009
@@ -271,25 +271,27 @@
   
 class PathDiagnosticSpotPiece : public PathDiagnosticPiece {
 private:
-  FullSourceLoc Pos;
+  PathDiagnosticLocation Pos;
 public:
-  PathDiagnosticSpotPiece(FullSourceLoc pos, const std::string& s,
+  PathDiagnosticSpotPiece(const PathDiagnosticLocation &pos,
+                          const std::string& s,
                           PathDiagnosticPiece::Kind k)
   : PathDiagnosticPiece(s, k), Pos(pos) {
-    assert(Pos.isValid() &&
+    assert(Pos.asLocation().isValid() &&
            "PathDiagnosticSpotPiece's must have a valid location.");
   }  
 
-  FullSourceLoc getLocation() const { return Pos; }
+  FullSourceLoc getLocation() const { return Pos.asLocation(); }
 };
   
 class PathDiagnosticEventPiece : public PathDiagnosticSpotPiece {
 
 public:
-  PathDiagnosticEventPiece(FullSourceLoc pos, const std::string& s)
+  PathDiagnosticEventPiece(const PathDiagnosticLocation &pos,
+                           const std::string& s)
     : PathDiagnosticSpotPiece(pos, s, Event) {}
   
-  PathDiagnosticEventPiece(FullSourceLoc pos, const char* s)
+  PathDiagnosticEventPiece(const PathDiagnosticLocation &pos, const char* s)
     : PathDiagnosticSpotPiece(pos, s, Event) {}
   
   ~PathDiagnosticEventPiece();
@@ -332,7 +334,7 @@
 class PathDiagnosticMacroPiece : public PathDiagnosticSpotPiece {
   std::vector<PathDiagnosticPiece*> SubPieces;
 public:
-  PathDiagnosticMacroPiece(FullSourceLoc pos)
+  PathDiagnosticMacroPiece(const PathDiagnosticLocation &pos)
     : PathDiagnosticSpotPiece(pos, "", Macro) {}
   
   ~PathDiagnosticMacroPiece();

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

==============================================================================
--- cfe/trunk/lib/Analysis/PathDiagnostic.cpp (original)
+++ cfe/trunk/lib/Analysis/PathDiagnostic.cpp Thu Mar 26 16:39:39 2009
@@ -12,6 +12,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang/Analysis/PathDiagnostic.h"
+#include "clang/AST/Expr.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/Casting.h"
 #include <sstream>
@@ -133,3 +134,17 @@
 
   HandlePathDiagnostic(D);  
 }
+
+//===----------------------------------------------------------------------===//
+// PathDiagnosticLocation methods.
+//===----------------------------------------------------------------------===//
+
+FullSourceLoc PathDiagnosticLocation::asLocation() const {
+  switch (K) {
+    case SingleLoc:
+    case Range:
+      return FullSourceLoc(R.getBegin(), const_cast<SourceManager&>(SM));
+    case Statement:
+      return FullSourceLoc(S->getLocStart(), const_cast<SourceManager&>(SM));
+  }
+}





More information about the cfe-commits mailing list