diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-09-19 20:40:35 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-09-19 20:40:35 +0000 |
commit | 7c06d8666b3f81051787159d2d5c7ff84270ae10 (patch) | |
tree | ada454a1a3f1276706bc219f9d78810fcc2ddb8d /clang/lib/Serialization/ASTReader.cpp | |
parent | 532c5196b016847ee4fcdb06bb6b1cbee774f3be (diff) | |
download | bcm5719-llvm-7c06d8666b3f81051787159d2d5c7ff84270ae10.tar.gz bcm5719-llvm-7c06d8666b3f81051787159d2d5c7ff84270ae10.zip |
[libclang] When getting a source location from a file:line:col triplet
check whether the requested location points inside the precompiled preamble,
in which case the returned source location will be a "loaded" one.
llvm-svn: 140060
Diffstat (limited to 'clang/lib/Serialization/ASTReader.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 0f3cad55139..02d7eeaa8dd 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -2508,23 +2508,15 @@ ASTReader::ASTReadResult ASTReader::ReadAST(const std::string &FileName, if (DeserializationListener) DeserializationListener->ReaderInitialized(this); - // If this AST file is a precompiled preamble, then set the main file ID of - // the source manager to the file source file from which the preamble was - // built. This is the only valid way to use a precompiled preamble. + // If this AST file is a precompiled preamble, then set the preamble file ID + // of the source manager to the file source file from which the preamble was + // built. if (Type == MK_Preamble) { - if (OriginalFileID.isInvalid()) { - SourceLocation Loc - = SourceMgr.getLocation(FileMgr.getFile(getOriginalSourceFile()), 1, 1); - if (Loc.isValid()) - OriginalFileID = SourceMgr.getDecomposedLoc(Loc).first; - } - else { + if (!OriginalFileID.isInvalid()) { OriginalFileID = FileID::get(ModuleMgr.getPrimaryModule().SLocEntryBaseID + OriginalFileID.getOpaqueValue() - 1); + SourceMgr.setPreambleFileID(OriginalFileID); } - - if (!OriginalFileID.isInvalid()) - SourceMgr.SetPreambleFileID(OriginalFileID); } return Success; |