}
// Finally, install the macro.
- II = II;
-#if 0
- // FIXME: Do this when predefines buffer is worked out.
PP.setMacroInfo(II, MI);
-#endif
// Remember that we saw this macro last so that we add the tokens that
// form its body to it.
// Load the translation unit declaration
ReadDeclRecord(DeclOffsets[0], 0);
+ // If everything looks like it will be ok, then the PCH file load succeeded.
+ // Since the PCH file contains everything that is in the preprocessor's
+ // predefines buffer (and we validated that they are the same) clear out the
+ // predefines buffer so that it doesn't get processed again.
+ PP.setPredefines("");
+
return false;
}
///
static bool InitializePreprocessor(Preprocessor &PP,
bool InitializeSourceMgr,
- const std::string &InFile) {
+ const std::string &InFile, bool UsesPCH) {
FileManager &FileMgr = PP.getFileManager();
// Figure out where to get and map in the main file.
}
}
+ // If the file is using PCH, then the PCH will include all the predefines, no
+ // need to install them now.
+ if (UsesPCH)
+ return false;
+
std::vector<char> PredefineBuffer;
// Install things like __POWERPC__, __GNUC__, etc into the macro table.
return PP.take();
}
- virtual bool FinishInitialization(Preprocessor *PP) {
- if (InitializePreprocessor(*PP, InitializeSourceMgr, InFile)) {
+ virtual bool FinishInitialization(Preprocessor *PP, bool UsesPCH) {
+ if (InitializePreprocessor(*PP, InitializeSourceMgr, InFile, UsesPCH))
return true;
- }
/// FIXME: PP can only handle one callback
if (ProgAction != PrintPreprocessedInput) {
// than earlier) because this initialization creates new source
// location entries in the source manager, which must come after
// the source location entries for the PCH file.
- if (PPF.FinishInitialization(&PP))
+ if (PPF.FinishInitialization(&PP, true /*uses PCH*/))
return;
}
continue;
if (ImplicitIncludePCH.empty()
- && PPFactory.FinishInitialization(PP.get()))
+ && PPFactory.FinishInitialization(PP.get(), false))
continue;
// Create the HTMLDiagnosticsClient if we are using one. Otherwise,