Implement PathDiagnosticLocation::asRange() and PathDiagnosticLocation::asStmt().

llvm-svn: 67777
This commit is contained in:
Ted Kremenek 2009-03-26 21:48:17 +00:00
parent c25116576f
commit 96110d5920
2 changed files with 16 additions and 1 deletions

View File

@ -67,7 +67,7 @@ public:
FullSourceLoc asLocation() const;
SourceRange asRange() const;
const Stmt *asStmt() const;
const Stmt *asStmt() const { return S ? S : 0; }
};
class PathDiagnostic {

View File

@ -152,3 +152,18 @@ FullSourceLoc PathDiagnosticLocation::asLocation() const {
return FullSourceLoc(R.getBegin(), const_cast<SourceManager&>(SM));
}
SourceRange PathDiagnosticLocation::asRange() const {
// Note that we want a 'switch' here so that the compiler can warn us in
// case we add more cases.
switch (K) {
case SingleLoc:
case Range:
break;
case Statement:
return S->getSourceRange();
}
return R;
}