Handle invalid ASTLocations instead of asserting.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76335 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Index/ASTLocation.cpp b/lib/Index/ASTLocation.cpp
index f73ddc0..d83e0e3 100644
--- a/lib/Index/ASTLocation.cpp
+++ b/lib/Index/ASTLocation.cpp
@@ -83,11 +83,16 @@
}
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()))