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();
class PathDiagnosticMacroPiece : public PathDiagnosticSpotPiece {
std::vector<PathDiagnosticPiece*> SubPieces;
public:
- PathDiagnosticMacroPiece(FullSourceLoc pos)
+ PathDiagnosticMacroPiece(const PathDiagnosticLocation &pos)
: PathDiagnosticSpotPiece(pos, "", Macro) {}
~PathDiagnosticMacroPiece();
//===----------------------------------------------------------------------===//
#include "clang/Analysis/PathDiagnostic.h"
+#include "clang/AST/Expr.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/Casting.h"
#include <sstream>
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));
+ }
+}