diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-08-05 09:48:08 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-08-05 09:48:08 +0000 |
commit | 72b90571b1783b17c3f2204cec5ca440edc38bee (patch) | |
tree | a759b482778139e091bdea82a52414247cc30db2 /lib/Frontend | |
parent | 3f95477f28ef3baaf79001a5654785c8b2075710 (diff) |
Support #pragma weak for PCH.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110323 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend')
-rw-r--r-- | lib/Frontend/PCHReader.cpp | 24 | ||||
-rw-r--r-- | lib/Frontend/PCHWriter.cpp | 19 |
2 files changed, 43 insertions, 0 deletions
diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp index 2252fd4729..7229775070 100644 --- a/lib/Frontend/PCHReader.cpp +++ b/lib/Frontend/PCHReader.cpp @@ -1642,6 +1642,15 @@ PCHReader::ReadPCHBlock(PerFileData &F) { Record.begin(), Record.end()); break; + case pch::WEAK_UNDECLARED_IDENTIFIERS: + // Optimization for the first block. + if (WeakUndeclaredIdentifiers.empty()) + WeakUndeclaredIdentifiers.swap(Record); + else + WeakUndeclaredIdentifiers.insert(WeakUndeclaredIdentifiers.end(), + Record.begin(), Record.end()); + break; + case pch::LOCALLY_SCOPED_EXTERNAL_DECLS: // Optimization for the first block. if (LocallyScopedExternalDecls.empty()) @@ -3131,6 +3140,21 @@ void PCHReader::InitializeSema(Sema &S) { SemaObj->UnusedStaticFuncs.push_back(FD); } + // If there were any weak undeclared identifiers, deserialize them and add to + // Sema's list of weak undeclared identifiers. + if (!WeakUndeclaredIdentifiers.empty()) { + unsigned Idx = 0; + for (unsigned I = 0, N = WeakUndeclaredIdentifiers[Idx++]; I != N; ++I) { + IdentifierInfo *WeakId = GetIdentifierInfo(WeakUndeclaredIdentifiers,Idx); + IdentifierInfo *AliasId=GetIdentifierInfo(WeakUndeclaredIdentifiers,Idx); + SourceLocation Loc = ReadSourceLocation(WeakUndeclaredIdentifiers, Idx); + bool Used = WeakUndeclaredIdentifiers[Idx++]; + Sema::WeakInfo WI(AliasId, Loc); + WI.setUsed(Used); + SemaObj->WeakUndeclaredIdentifiers.insert(std::make_pair(WeakId, WI)); + } + } + // If there were any locally-scoped external declarations, // deserialize them and add them to Sema's table of locally-scoped // external declarations. diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp index b2fd984766..d6dc36fd30 100644 --- a/lib/Frontend/PCHWriter.cpp +++ b/lib/Frontend/PCHWriter.cpp @@ -2207,6 +2207,20 @@ void PCHWriter::WritePCHCore(Sema &SemaRef, MemorizeStatCalls *StatCalls, RecordData UnusedStaticFuncs; for (unsigned i=0, e = SemaRef.UnusedStaticFuncs.size(); i !=e; ++i) AddDeclRef(SemaRef.UnusedStaticFuncs[i], UnusedStaticFuncs); + + RecordData WeakUndeclaredIdentifiers; + if (!SemaRef.WeakUndeclaredIdentifiers.empty()) { + WeakUndeclaredIdentifiers.push_back( + SemaRef.WeakUndeclaredIdentifiers.size()); + for (llvm::DenseMap<IdentifierInfo*,Sema::WeakInfo>::iterator + I = SemaRef.WeakUndeclaredIdentifiers.begin(), + E = SemaRef.WeakUndeclaredIdentifiers.end(); I != E; ++I) { + AddIdentifierRef(I->first, WeakUndeclaredIdentifiers); + AddIdentifierRef(I->second.getAlias(), WeakUndeclaredIdentifiers); + AddSourceLocation(I->second.getLocation(), WeakUndeclaredIdentifiers); + WeakUndeclaredIdentifiers.push_back(I->second.getUsed()); + } + } // Build a record containing all of the locally-scoped external // declarations in this header file. Generally, this record will be @@ -2311,6 +2325,11 @@ void PCHWriter::WritePCHCore(Sema &SemaRef, MemorizeStatCalls *StatCalls, if (!UnusedStaticFuncs.empty()) Stream.EmitRecord(pch::UNUSED_STATIC_FUNCS, UnusedStaticFuncs); + // Write the record containing weak undeclared identifiers. + if (!WeakUndeclaredIdentifiers.empty()) + Stream.EmitRecord(pch::WEAK_UNDECLARED_IDENTIFIERS, + WeakUndeclaredIdentifiers); + // Write the record containing locally-scoped external definitions. if (!LocallyScopedExternalDecls.empty()) Stream.EmitRecord(pch::LOCALLY_SCOPED_EXTERNAL_DECLS, |