aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/PCHReader.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-03-16 16:35:32 +0000
committerDouglas Gregor <dgregor@apple.com>2010-03-16 16:35:32 +0000
commit12fab31aa5868b1a6b52246b5a87daa48a338fe2 (patch)
tree21cb1d2e0ebe6d1c1add8f5bc5705b77da597d57 /lib/Frontend/PCHReader.cpp
parentceafc4b63599d14f0b5b10ff92e22bf242682dce (diff)
Fix header-search problems with precompiled headers, where the
presence or absence of header map arguments when using the precompiled header would cause Clang to get confused about which headers had already been included/imported, along with their controlling macros. The fundamental problem is that the serialization of the header search information was relying on the UIDs of FileEntry objects at PCH generation time and PCH load time to be equivalent, which effectively means that we had to probe the same files in the same order. Differing header map arguments caused an extra FileEntry lookup, but it's easy to imagine other minor command-line arguments triggering this problem. Header-search information is now encoded along with the source-location entry for a file, so that we register information about a file's properties as a header at the same time we create the FileEntry for that file. Fixes <rdar://problem/7743243>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98636 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/PCHReader.cpp')
-rw-r--r--lib/Frontend/PCHReader.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp
index 49eb2a0e60..f1c0247b81 100644
--- a/lib/Frontend/PCHReader.cpp
+++ b/lib/Frontend/PCHReader.cpp
@@ -300,8 +300,10 @@ bool PCHValidator::ReadPredefinesBuffer(llvm::StringRef PCHPredef,
return false;
}
-void PCHValidator::ReadHeaderFileInfo(const HeaderFileInfo &HFI) {
- PP.getHeaderSearchInfo().setHeaderFileInfoForUID(HFI, NumHeaderInfos++);
+void PCHValidator::ReadHeaderFileInfo(const HeaderFileInfo &HFI,
+ unsigned ID) {
+ PP.getHeaderSearchInfo().setHeaderFileInfoForUID(HFI, ID);
+ ++NumHeaderInfos;
}
void PCHValidator::ReadCounter(unsigned Value) {
@@ -850,17 +852,6 @@ PCHReader::PCHReadResult PCHReader::ReadSourceManagerBlock() {
return Failure;
break;
- case pch::SM_HEADER_FILE_INFO: {
- HeaderFileInfo HFI;
- HFI.isImport = Record[0];
- HFI.DirInfo = Record[1];
- HFI.NumIncludes = Record[2];
- HFI.ControllingMacroID = Record[3];
- if (Listener)
- Listener->ReadHeaderFileInfo(HFI);
- break;
- }
-
case pch::SM_SLOC_FILE_ENTRY:
case pch::SM_SLOC_BUFFER_ENTRY:
case pch::SM_SLOC_INSTANTIATION_ENTRY:
@@ -918,6 +909,14 @@ PCHReader::PCHReadResult PCHReader::ReadSLocEntryRecord(unsigned ID) {
const_cast<SrcMgr::FileInfo&>(SourceMgr.getSLocEntry(FID).getFile())
.setHasLineDirectives();
+ // Reconstruct header-search information for this file.
+ HeaderFileInfo HFI;
+ HFI.isImport = Record[4];
+ HFI.DirInfo = Record[5];
+ HFI.NumIncludes = Record[6];
+ HFI.ControllingMacroID = Record[7];
+ if (Listener)
+ Listener->ReadHeaderFileInfo(HFI, File->getUID());
break;
}