aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-03-26 21:39:39 +0000
committerTed Kremenek <kremenek@apple.com>2009-03-26 21:39:39 +0000
commit97b40036d4d4d1bf4e7be71fc2bce009de4e8c0c (patch)
treed2f2d461d2dac6eb923cd8931b483c48d9d91baf
parentad75653f81dece1c806e9c28dd7e7582c9929a27 (diff)
- Implement PathDiagnosticLocation::asLocation.
- Switch PathDiagnosticEventPiece and PathDiagnosticMacroPiece to use PathDiagnosticLocation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67774 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Analysis/PathDiagnostic.h16
-rw-r--r--lib/Analysis/PathDiagnostic.cpp15
2 files changed, 24 insertions, 7 deletions
diff --git a/include/clang/Analysis/PathDiagnostic.h b/include/clang/Analysis/PathDiagnostic.h
index abf37f7079..f647be9d6d 100644
--- a/include/clang/Analysis/PathDiagnostic.h
+++ b/include/clang/Analysis/PathDiagnostic.h
@@ -271,25 +271,27 @@ public:
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 @@ public:
class PathDiagnosticMacroPiece : public PathDiagnosticSpotPiece {
std::vector<PathDiagnosticPiece*> SubPieces;
public:
- PathDiagnosticMacroPiece(FullSourceLoc pos)
+ PathDiagnosticMacroPiece(const PathDiagnosticLocation &pos)
: PathDiagnosticSpotPiece(pos, "", Macro) {}
~PathDiagnosticMacroPiece();
diff --git a/lib/Analysis/PathDiagnostic.cpp b/lib/Analysis/PathDiagnostic.cpp
index 0ccb900645..940a9e2d98 100644
--- a/lib/Analysis/PathDiagnostic.cpp
+++ b/lib/Analysis/PathDiagnostic.cpp
@@ -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 @@ void PathDiagnosticClient::HandleDiagnostic(Diagnostic::Level DiagLevel,
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));
+ }
+}