aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-08-02 07:14:54 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-08-02 07:14:54 +0000
commit76c38d385447b7acdff2d7e6b13fa8580e7174a7 (patch)
treebfb82295d787e7a08e757fd809ee0867898cf794 /lib/Frontend
parent26faaac4b636eafc2d686516f068170652c83fd9 (diff)
Read/write in PCH Sema's StdNamespace and StdBadAlloc and use a LazyDeclPtr for them that will deserialize them when needed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110031 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend')
-rw-r--r--lib/Frontend/PCHReader.cpp16
-rw-r--r--lib/Frontend/PCHWriter.cpp11
2 files changed, 27 insertions, 0 deletions
diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp
index 5a239e4f04..0502e674a9 100644
--- a/lib/Frontend/PCHReader.cpp
+++ b/lib/Frontend/PCHReader.cpp
@@ -1728,6 +1728,14 @@ PCHReader::ReadPCHBlock(PerFileData &F) {
DynamicClasses.swap(Record);
break;
+ case pch::SEMA_DECL_REFS:
+ if (!SemaDeclRefs.empty()) {
+ Error("duplicate SEMA_DECL_REFS record in PCH file");
+ return Failure;
+ }
+ SemaDeclRefs.swap(Record);
+ break;
+
case pch::ORIGINAL_FILE_NAME:
// The primary PCH will be the last to get here, so it will be the one
// that's used.
@@ -3152,6 +3160,14 @@ void PCHReader::InitializeSema(Sema &S) {
SemaObj->DynamicClasses.push_back(
cast<CXXRecordDecl>(GetDecl(DynamicClasses[I])));
+ // Load the offsets of the declarations that Sema references.
+ // They will be lazily deserialized when needed.
+ if (!SemaDeclRefs.empty()) {
+ assert(SemaDeclRefs.size() == 2 && "More decl refs than expected!");
+ SemaObj->StdNamespace = SemaDeclRefs[0];
+ SemaObj->StdBadAlloc = SemaDeclRefs[1];
+ }
+
// If there are @selector references added them to its pool. This is for
// implementation of -Wselector.
PerFileData &F = *Chain[0];
diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp
index a72f7cfea8..8bf85efd62 100644
--- a/lib/Frontend/PCHWriter.cpp
+++ b/lib/Frontend/PCHWriter.cpp
@@ -2243,6 +2243,13 @@ void PCHWriter::WritePCHCore(Sema &SemaRef, MemorizeStatCalls *StatCalls,
for (unsigned I = 0, N = SemaRef.DynamicClasses.size(); I != N; ++I)
AddDeclRef(SemaRef.DynamicClasses[I], DynamicClasses);
+ // Build a record containing some declaration references.
+ RecordData SemaDeclRefs;
+ if (SemaRef.StdNamespace || SemaRef.StdBadAlloc) {
+ AddDeclRef(SemaRef.getStdNamespace(), SemaDeclRefs);
+ AddDeclRef(SemaRef.getStdBadAlloc(), SemaDeclRefs);
+ }
+
// Write the remaining PCH contents.
RecordData Record;
Stream.EnterSubblock(pch::PCH_BLOCK_ID, 5);
@@ -2323,6 +2330,10 @@ void PCHWriter::WritePCHCore(Sema &SemaRef, MemorizeStatCalls *StatCalls,
if (!DynamicClasses.empty())
Stream.EmitRecord(pch::DYNAMIC_CLASSES, DynamicClasses);
+ // Write the record containing declaration references of Sema.
+ if (!SemaDeclRefs.empty())
+ Stream.EmitRecord(pch::SEMA_DECL_REFS, SemaDeclRefs);
+
// Some simple statistics
Record.clear();
Record.push_back(NumStatements);