[cfe-commits] r166228 - in /cfe/trunk: include/clang/Serialization/ASTReader.h include/clang/Serialization/Module.h lib/Serialization/ASTReader.cpp
Douglas Gregor
dgregor at apple.com
Thu Oct 18 14:18:25 PDT 2012
Author: dgregor
Date: Thu Oct 18 16:18:25 2012
New Revision: 166228
URL: http://llvm.org/viewvc/llvm-project?rev=166228&view=rev
Log:
Move information about the "original file" from the ASTReader into the
module files.
Modified:
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/include/clang/Serialization/Module.h
cfe/trunk/lib/Serialization/ASTReader.cpp
Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=166228&r1=166227&r2=166228&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Thu Oct 18 16:18:25 2012
@@ -645,18 +645,6 @@
SmallVector<serialization::SubmoduleID, 2> ImportedModules;
//@}
- /// \brief The original file name that was used to build the primary AST file,
- /// which may have been modified for relocatable-pch support.
- std::string OriginalFileName;
-
- /// \brief The actual original file name that was used to build the primary
- /// AST file.
- std::string ActualOriginalFileName;
-
- /// \brief The file ID for the original file that was used to build the
- /// primary AST file.
- FileID OriginalFileID;
-
/// \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;
@@ -1106,8 +1094,11 @@
/// \brief Retrieve the preprocessor.
Preprocessor &getPreprocessor() const { return PP; }
- /// \brief Retrieve the name of the original source file name
- const std::string &getOriginalSourceFile() { return OriginalFileName; }
+ /// \brief Retrieve the name of the original source file name for the primary
+ /// module file.
+ const std::string &getOriginalSourceFile() {
+ return ModuleMgr.getPrimaryModule().OriginalSourceFileName;
+ }
/// \brief Retrieve the name of the original source file name directly from
/// the AST file, without actually loading the AST file.
Modified: cfe/trunk/include/clang/Serialization/Module.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/Module.h?rev=166228&r1=166227&r2=166228&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/Module.h (original)
+++ cfe/trunk/include/clang/Serialization/Module.h Thu Oct 18 16:18:25 2012
@@ -75,6 +75,23 @@
/// \brief The file name of the module file.
std::string FileName;
+ /// \brief The original source file name that was used to build the
+ /// primary AST file, which may have been modified for
+ /// relocatable-pch support.
+ std::string OriginalSourceFileName;
+
+ /// \brief The actual original source file name that was used to
+ /// build this AST file.
+ std::string ActualOriginalSourceFileName;
+
+ /// \brief The file ID for the original source file that was used to
+ /// build this AST file.
+ FileID OriginalSourceFileID;
+
+ /// \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 file entry for the module file.
const FileEntry *File;
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=166228&r1=166227&r2=166228&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Oct 18 16:18:25 2012
@@ -819,11 +819,14 @@
/// \brief Tell the AST listener about the predefines buffers in the chain.
bool ASTReader::CheckPredefinesBuffers() {
- if (Listener)
+ if (Listener) {
+ // We only care about the primary module.
+ ModuleFile &M = ModuleMgr.getPrimaryModule();
return Listener->ReadPredefinesBuffer(PCHPredefinesBuffers,
- ActualOriginalFileName,
+ M.ActualOriginalSourceFileName,
SuggestedPredefines,
FileMgr);
+ }
return false;
}
@@ -1833,7 +1836,7 @@
}
case LANGUAGE_OPTIONS:
- if (&F == *ModuleMgr.begin() &&
+ if (Listener && &F == *ModuleMgr.begin() &&
ParseLanguageOptions(F, Record) && !DisableValidation)
return IgnorePCH;
break;
@@ -1854,7 +1857,7 @@
TargetOpts.Features.push_back(ReadString(Record, Idx));
}
- if (Listener->ReadTargetOptions(F, TargetOpts))
+ if (Listener->ReadTargetOptions(F, TargetOpts) && !DisableValidation)
return IgnorePCH;
}
break;
@@ -1863,11 +1866,10 @@
case ORIGINAL_FILE:
// Only record from the primary AST file.
if (&F == *ModuleMgr.begin()) {
- OriginalFileID = FileID::get(Record[0]);
-
- ActualOriginalFileName.assign(BlobStart, BlobLen);
- OriginalFileName = ActualOriginalFileName;
- MaybeAddSystemRootToFilename(OriginalFileName);
+ F.OriginalSourceFileID = FileID::get(Record[0]);
+ F.ActualOriginalSourceFileName.assign(BlobStart, BlobLen);
+ F.OriginalSourceFileName = F.ActualOriginalSourceFileName;
+ MaybeAddSystemRootToFilename(F.OriginalSourceFileName);
}
break;
@@ -2980,17 +2982,19 @@
if (DeserializationListener)
DeserializationListener->ReaderInitialized(this);
- if (!OriginalFileID.isInvalid()) {
- OriginalFileID = FileID::get(ModuleMgr.getPrimaryModule().SLocEntryBaseID
- + OriginalFileID.getOpaqueValue() - 1);
-
- // 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.
+ ModuleFile &PrimaryModule = ModuleMgr.getPrimaryModule();
+ if (!PrimaryModule.OriginalSourceFileID.isInvalid()) {
+ PrimaryModule.OriginalSourceFileID
+ = FileID::get(PrimaryModule.SLocEntryBaseID
+ + PrimaryModule.OriginalSourceFileID.getOpaqueValue() - 1);
+
+ // 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) {
- SourceMgr.setPreambleFileID(OriginalFileID);
+ SourceMgr.setPreambleFileID(PrimaryModule.OriginalSourceFileID);
} else if (Type == MK_MainFile) {
- SourceMgr.setMainFileID(OriginalFileID);
+ SourceMgr.setMainFileID(PrimaryModule.OriginalSourceFileID);
}
}
More information about the cfe-commits
mailing list