Handle invalid ASTLocations instead of asserting.
llvm-svn: 76335
This commit is contained in:
parent
e376b53c7b
commit
fb63b0a317
|
@ -83,11 +83,16 @@ bool ASTLocation::isImmediateParent(Decl *D, Stmt *Node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SourceRange ASTLocation::getSourceRange() const {
|
SourceRange ASTLocation::getSourceRange() const {
|
||||||
|
if (isInvalid())
|
||||||
|
return SourceRange();
|
||||||
return isDecl() ? getDecl()->getSourceRange() : getStmt()->getSourceRange();
|
return isDecl() ? getDecl()->getSourceRange() : getStmt()->getSourceRange();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASTLocation::print(llvm::raw_ostream &OS) {
|
void ASTLocation::print(llvm::raw_ostream &OS) {
|
||||||
assert(isValid() && "ASTLocation is not valid");
|
if (isInvalid()) {
|
||||||
|
OS << "<< Invalid ASTLocation >>\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
OS << "[Decl: " << getDecl()->getDeclKindName() << " ";
|
OS << "[Decl: " << getDecl()->getDeclKindName() << " ";
|
||||||
if (NamedDecl *ND = dyn_cast<NamedDecl>(getDecl()))
|
if (NamedDecl *ND = dyn_cast<NamedDecl>(getDecl()))
|
||||||
|
|
Loading…
Reference in New Issue