diff options
author | Sean Callanan <scallanan@apple.com> | 2014-12-10 01:26:39 +0000 |
---|---|---|
committer | Sean Callanan <scallanan@apple.com> | 2014-12-10 01:26:39 +0000 |
commit | 238d897b07ff986b086c0a37e465dbc4310307e5 (patch) | |
tree | dcf2cd39f3b49a3635888bc6352b16b52b221fb0 /clang/lib/AST/ASTImporter.cpp | |
parent | 84f798f0ebcc285e7b46eb84cb358b006369244d (diff) | |
download | bcm5719-llvm-238d897b07ff986b086c0a37e465dbc4310307e5.tar.gz bcm5719-llvm-238d897b07ff986b086c0a37e465dbc4310307e5.zip |
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
Diffstat (limited to 'clang/lib/AST/ASTImporter.cpp')
-rw-r--r-- | clang/lib/AST/ASTImporter.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index 88e5a41e60b..009ea1f2b15 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<FileID, unsigned> 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 { |