]> granicus.if.org Git - clang/commitdiff
Handle invalid ASTLocations instead of asserting.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 18 Jul 2009 21:17:43 +0000 (21:17 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 18 Jul 2009 21:17:43 +0000 (21:17 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76335 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Index/ASTLocation.cpp

index f73ddc087aa34e929c5f6821fc3e95771fe01f72..d83e0e33f35b4e7a9660fbbad34f56ae5fe38f6d 100644 (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()))