Handle invalid ASTLocations instead of asserting.

llvm-svn: 76335
This commit is contained in:
Argyrios Kyrtzidis 2009-07-18 21:17:43 +00:00
parent e376b53c7b
commit fb63b0a317
1 changed files with 6 additions and 1 deletions

View File

@ -83,11 +83,16 @@ bool ASTLocation::isImmediateParent(Decl *D, Stmt *Node) {
}
SourceRange ASTLocation::getSourceRange() const {
if (isInvalid())
return SourceRange();
return isDecl() ? getDecl()->getSourceRange() : getStmt()->getSourceRange();
}
void ASTLocation::print(llvm::raw_ostream &OS) {
assert(isValid() && "ASTLocation is not valid");
if (isInvalid()) {
OS << "<< Invalid ASTLocation >>\n";
return;
}
OS << "[Decl: " << getDecl()->getDeclKindName() << " ";
if (NamedDecl *ND = dyn_cast<NamedDecl>(getDecl()))