From 69e160869dc10567a878601e98987079ad984c64 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 18 Oct 2012 21:47:16 +0000 Subject: [PATCH] Move OriginalDir from ASTReader to ModuleFile. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166233 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Serialization/ASTReader.h | 4 ---- lib/Serialization/ASTReader.cpp | 31 +++++++++++-------------- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h index f65de63fd3..7d9792e0fe 100644 --- a/include/clang/Serialization/ASTReader.h +++ b/include/clang/Serialization/ASTReader.h @@ -645,10 +645,6 @@ private: SmallVector ImportedModules; //@} - /// \brief The directory that the PCH was originally created in. Used to - /// allow resolving headers even after headers+PCH was moved to a new path. - std::string OriginalDir; - /// \brief The directory that the PCH we are reading is stored in. std::string CurrentDir; diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 1322be5a23..fe2affb91e 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -1130,10 +1130,10 @@ ASTReader::ASTReadResult ASTReader::ReadSLocEntryRecord(int ID) { OverriddenBuffer? FileMgr.getVirtualFile(Filename, (off_t)Record[4], (time_t)Record[5]) : FileMgr.getFile(Filename, /*OpenFile=*/false); - if (File == 0 && !OriginalDir.empty() && !CurrentDir.empty() && - OriginalDir != CurrentDir) { + if (File == 0 && !F->OriginalDir.empty() && !CurrentDir.empty() && + F->OriginalDir != CurrentDir) { std::string resolved = resolveFileRelativeToOriginalDir(Filename, - OriginalDir, + F->OriginalDir, CurrentDir); if (!resolved.empty()) File = FileMgr.getFile(resolved); @@ -1708,13 +1708,14 @@ void ASTReader::markIdentifierUpToDate(IdentifierInfo *II) { } const FileEntry *ASTReader::getFileEntry(StringRef filenameStrRef) { + ModuleFile &M = ModuleMgr.getPrimaryModule(); std::string Filename = filenameStrRef; - MaybeAddSystemRootToFilename(ModuleMgr.getPrimaryModule(), Filename); + MaybeAddSystemRootToFilename(M, Filename); const FileEntry *File = FileMgr.getFile(Filename); - if (File == 0 && !OriginalDir.empty() && !CurrentDir.empty() && - OriginalDir != CurrentDir) { + if (File == 0 && !M.OriginalDir.empty() && !CurrentDir.empty() && + M.OriginalDir != CurrentDir) { std::string resolved = resolveFileRelativeToOriginalDir(Filename, - OriginalDir, + M.OriginalDir, CurrentDir); if (!resolved.empty()) File = FileMgr.getFile(resolved); @@ -1865,20 +1866,14 @@ ASTReader::ASTReadResult ASTReader::ReadControlBlock(ModuleFile &F, } case ORIGINAL_FILE: - // Only record from the primary AST file. - if (&F == *ModuleMgr.begin()) { - F.OriginalSourceFileID = FileID::get(Record[0]); - F.ActualOriginalSourceFileName.assign(BlobStart, BlobLen); - F.OriginalSourceFileName = F.ActualOriginalSourceFileName; - MaybeAddSystemRootToFilename(F, F.OriginalSourceFileName); - } + F.OriginalSourceFileID = FileID::get(Record[0]); + F.ActualOriginalSourceFileName.assign(BlobStart, BlobLen); + F.OriginalSourceFileName = F.ActualOriginalSourceFileName; + MaybeAddSystemRootToFilename(F, F.OriginalSourceFileName); break; case ORIGINAL_PCH_DIR: - // Only record from the primary AST file. - if (&F == *ModuleMgr.begin()) { - OriginalDir.assign(BlobStart, BlobLen); - } + F.OriginalDir.assign(BlobStart, BlobLen); break; } } -- 2.40.0