Allow some differences between the predefines buffer used to build a
PCH file and the predefines buffer used when including the PCH
file. We (explicitly) detect conflicting macro definitions (rejecting
the PCH file) and about missing macro definitions (they'll be
automatically pulled from the PCH file anyway).
We're missing some checking to make sure that new macro definitions
won't have any impact on the PCH file itself (e.g., #define'ing an
identifier that the PCH file used).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70316 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/clang-cc/clang-cc.cpp b/tools/clang-cc/clang-cc.cpp
index 92452ec..ad00664 100644
--- a/tools/clang-cc/clang-cc.cpp
+++ b/tools/clang-cc/clang-cc.cpp
@@ -1755,6 +1755,10 @@
// the precompiled header into the AST context.
switch (Reader->ReadPCH(ImplicitIncludePCH)) {
case PCHReader::Success: {
+ // Set the predefines buffer as suggested by the PCH
+ // reader. Typically, the predefines buffer will be empty.
+ PP.setPredefines(Reader->getSuggestedPredefines());
+
// Attach the PCH reader to the AST context as an external AST
// source, so that declarations will be deserialized from the
// PCH file as needed.
@@ -1762,10 +1766,6 @@
Source.reset(Reader.take());
ContextOwner->setExternalSource(Source);
}
-
- // Clear out the predefines buffer, because all of the
- // predefines are already in the PCH file.
- PP.setPredefines("");
break;
}