aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-04-22 22:02:47 +0000
committerDouglas Gregor <dgregor@apple.com>2009-04-22 22:02:47 +0000
commit4c0e86b392c5fb0cb771551fc877edb6979be69c (patch)
tree306e990e26b85259ec6b751ae4294ea4a263a9b3 /lib/Frontend
parent370187c8a3e96517c943329f2511737a04b85450 (diff)
Support tentative definitions in precompiled headers. This isn't likely
to happen (ever), but at least we'll do the right thing when it does. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69829 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend')
-rw-r--r--lib/Frontend/PCHReader.cpp14
-rw-r--r--lib/Frontend/PCHWriter.cpp14
2 files changed, 28 insertions, 0 deletions
diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp
index 6de13045bb..28cca4d0ff 100644
--- a/lib/Frontend/PCHReader.cpp
+++ b/lib/Frontend/PCHReader.cpp
@@ -1713,6 +1713,13 @@ PCHReader::ReadPCHBlock(uint64_t &PreprocessorBlockOffset) {
TotalNumMacros = Record[1];
break;
+ case pch::TENTATIVE_DEFINITIONS:
+ if (!TentativeDefinitions.empty()) {
+ Error("Duplicate TENTATIVE_DEFINITIONS record in PCH file");
+ return Failure;
+ }
+ TentativeDefinitions.swap(Record);
+ break;
}
}
@@ -2523,6 +2530,13 @@ void PCHReader::InitializeSema(Sema &S) {
SemaObj->IdResolver.AddDecl(PreloadedDecls[I]);
}
PreloadedDecls.clear();
+
+ // If there were any tentative definitions, deserialize them and add
+ // them to Sema's table of tentative definitions.
+ for (unsigned I = 0, N = TentativeDefinitions.size(); I != N; ++I) {
+ VarDecl *Var = cast<VarDecl>(GetDecl(TentativeDefinitions[I]));
+ SemaObj->TentativeDefinitions[Var->getDeclName()] = Var;
+ }
}
IdentifierInfo* PCHReader::get(const char *NameStart, const char *NameEnd) {
diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp
index b081a2813f..097ced2363 100644
--- a/lib/Frontend/PCHWriter.cpp
+++ b/lib/Frontend/PCHWriter.cpp
@@ -2024,6 +2024,15 @@ void PCHWriter::WritePCH(Sema &SemaRef) {
getIdentifierRef(&Table.get(BuiltinNames[I]));
}
+ // Build a record containing all of the tentative definitions in
+ // this header file. Generally, this record will be empty.
+ RecordData TentativeDefinitions;
+ for (llvm::DenseMap<DeclarationName, VarDecl *>::iterator
+ TD = SemaRef.TentativeDefinitions.begin(),
+ TDEnd = SemaRef.TentativeDefinitions.end();
+ TD != TDEnd; ++TD)
+ AddDeclRef(TD->second, TentativeDefinitions);
+
// Write the remaining PCH contents.
RecordData Record;
Stream.EnterSubblock(pch::PCH_BLOCK_ID, 3);
@@ -2042,8 +2051,13 @@ void PCHWriter::WritePCH(Sema &SemaRef) {
AddTypeRef(Context.getBuiltinVaListType(), Record);
Stream.EmitRecord(pch::SPECIAL_TYPES, Record);
+ // Write the record containing external, unnamed definitions.
if (!ExternalDefinitions.empty())
Stream.EmitRecord(pch::EXTERNAL_DEFINITIONS, ExternalDefinitions);
+
+ // Write the record containing tentative definitions.
+ if (!TentativeDefinitions.empty())
+ Stream.EmitRecord(pch::TENTATIVE_DEFINITIONS, TentativeDefinitions);
// Some simple statistics
Record.clear();