diff options
Diffstat (limited to 'lib/Serialization/ASTReader.cpp')
-rw-r--r-- | lib/Serialization/ASTReader.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 86732484bc..1cac948d03 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -2239,6 +2239,18 @@ 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 (Type == Preamble) { + SourceLocation Loc + = SourceMgr.getLocation(FileMgr.getFile(getOriginalSourceFile()), 1, 1); + if (Loc.isValid()) { + std::pair<FileID, unsigned> Decomposed = SourceMgr.getDecomposedLoc(Loc); + SourceMgr.SetPreambleFileID(Decomposed.first); + } + } + return Success; } |