From: Sean Callanan Date: Wed, 10 Dec 2014 01:26:39 +0000 (+0000) Subject: Made the ASTImporter resilient if it can't import X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=238d897b07ff986b086c0a37e465dbc4310307e5;p=platform%2Fupstream%2Fllvm.git Made the ASTImporter resilient if it can't import SourceLocations. LLDB rarely has the same files mapped into the target AST context as the source AST context, so the ASTImporter shouldn't expect to see those files there. This started to become a problem when importing entities from modules -- these have proper source locations, in contrast to all the ASTs LLDB creates which have empty ones. llvm-svn: 223900 --- diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index 88e5a41..009ea1f 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -4923,7 +4923,10 @@ SourceLocation ASTImporter::Import(SourceLocation FromLoc) { FromLoc = FromSM.getSpellingLoc(FromLoc); std::pair Decomposed = FromSM.getDecomposedLoc(FromLoc); SourceManager &ToSM = ToContext.getSourceManager(); - return ToSM.getLocForStartOfFile(Import(Decomposed.first)) + FileID ToFileID = Import(Decomposed.first); + if (ToFileID.isInvalid()) + return SourceLocation(); + return ToSM.getLocForStartOfFile(ToFileID) .getLocWithOffset(Decomposed.second); } @@ -4954,6 +4957,8 @@ FileID ASTImporter::Import(FileID FromID) { // FIXME: We definitely want to re-use the existing MemoryBuffer, rather // than mmap the files several times. const FileEntry *Entry = ToFileManager.getFile(Cache->OrigEntry->getName()); + if (!Entry) + return FileID(); ToID = ToSM.createFileID(Entry, ToIncludeLoc, FromSLoc.getFile().getFileCharacteristic()); } else {