summaryrefslogtreecommitdiffstats
path: root/clang/lib/Index/ASTLocation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Index/ASTLocation.cpp')
-rw-r--r--clang/lib/Index/ASTLocation.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Index/ASTLocation.cpp b/clang/lib/Index/ASTLocation.cpp
index f73ddc087aa..d83e0e33f35 100644
--- a/clang/lib/Index/ASTLocation.cpp
+++ b/clang/lib/Index/ASTLocation.cpp
@@ -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()))
OpenPOWER on IntegriCloud