summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-04-22 22:26:10 +0000
committerTed Kremenek <kremenek@apple.com>2009-04-22 22:26:10 +0000
commit63e29cc99c349e5fcc8828a084978b910615a5ad (patch)
tree5698ae439e520d0a916e4d9af6ecf1a5aba3d99c
parentacfc76cc636f2dc46c921a4c7fa41d51d8bf447d (diff)
downloadbcm5719-llvm-63e29cc99c349e5fcc8828a084978b910615a5ad.tar.gz
bcm5719-llvm-63e29cc99c349e5fcc8828a084978b910615a5ad.zip
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. llvm-svn: 69834
-rw-r--r--clang/include/clang/Analysis/PathDiagnostic.h10
-rw-r--r--clang/lib/Analysis/PathDiagnostic.cpp5
-rw-r--r--clang/lib/Frontend/PlistDiagnostics.cpp4
3 files changed, 14 insertions, 5 deletions
diff --git a/clang/include/clang/Analysis/PathDiagnostic.h b/clang/include/clang/Analysis/PathDiagnostic.h
index 0e0b85eb109..84fe8d92c60 100644
--- a/clang/include/clang/Analysis/PathDiagnostic.h
+++ b/clang/include/clang/Analysis/PathDiagnostic.h
@@ -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; }
diff --git a/clang/lib/Analysis/PathDiagnostic.cpp b/clang/lib/Analysis/PathDiagnostic.cpp
index fa075a39595..946548e02cc 100644
--- a/clang/lib/Analysis/PathDiagnostic.cpp
+++ b/clang/lib/Analysis/PathDiagnostic.cpp
@@ -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);
}
}
diff --git a/clang/lib/Frontend/PlistDiagnostics.cpp b/clang/lib/Frontend/PlistDiagnostics.cpp
index d67740aa9d6..7ad900e8741 100644
--- a/clang/lib/Frontend/PlistDiagnostics.cpp
+++ b/clang/lib/Frontend/PlistDiagnostics.cpp
@@ -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";
}
OpenPOWER on IntegriCloud