diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-04-28 20:33:11 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-04-28 20:33:11 +0000 |
commit | 92b059ea944adaa3e00bb53d63a09868a4752547 (patch) | |
tree | 2fbfb91154b92fe0f593eb05ed715284df375873 /lib/Frontend/PCHWriter.cpp | |
parent | 02fc75169afe785c114e795ec4d24edfb4073c42 (diff) |
Implement checking for macro definitions that occur on the command
line when using a PCH that were not provided when building the PCH
file. If those names were used as identifiers somewhere in the PCH
file, reject the PCH file.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70321 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/PCHWriter.cpp')
-rw-r--r-- | lib/Frontend/PCHWriter.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp index e61cca554b..11f620279c 100644 --- a/lib/Frontend/PCHWriter.cpp +++ b/lib/Frontend/PCHWriter.cpp @@ -1378,11 +1378,21 @@ void PCHWriter::WriteIdentifierTable(Preprocessor &PP) { // Create and write out the blob that contains the identifier // strings. - IdentifierOffsets.resize(IdentifierIDs.size()); { OnDiskChainedHashTableGenerator<PCHIdentifierTableTrait> Generator; + // Look for any identifiers that were named while processing the + // headers, but are otherwise not needed. We add these to the hash + // table to enable checking of the predefines buffer in the case + // where the user adds new macro definitions when building the PCH + // file. + for (IdentifierTable::iterator ID = PP.getIdentifierTable().begin(), + IDEnd = PP.getIdentifierTable().end(); + ID != IDEnd; ++ID) + getIdentifierRef(ID->second); + // Create the on-disk hash table representation. + IdentifierOffsets.resize(IdentifierIDs.size()); for (llvm::DenseMap<const IdentifierInfo *, pch::IdentID>::iterator ID = IdentifierIDs.begin(), IDEnd = IdentifierIDs.end(); ID != IDEnd; ++ID) { |