|
@@ -458,10 +458,16 @@ bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) {
|
|
SourceMgr.setNumCreatedFIDsForFileID(CurPPLexer->getFileID(), NumFIDs);
|
|
SourceMgr.setNumCreatedFIDsForFileID(CurPPLexer->getFileID(), NumFIDs);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ bool ExitedFromPredefinesFile = false;
|
|
FileID ExitedFID;
|
|
FileID ExitedFID;
|
|
- if (Callbacks && !isEndOfMacro && CurPPLexer)
|
|
|
|
|
|
+ if (!isEndOfMacro && CurPPLexer) {
|
|
ExitedFID = CurPPLexer->getFileID();
|
|
ExitedFID = CurPPLexer->getFileID();
|
|
|
|
|
|
|
|
+ assert(PredefinesFileID.isValid() &&
|
|
|
|
+ "HandleEndOfFile is called before PredefinesFileId is set");
|
|
|
|
+ ExitedFromPredefinesFile = (PredefinesFileID == ExitedFID);
|
|
|
|
+ }
|
|
|
|
+
|
|
if (LeavingSubmodule) {
|
|
if (LeavingSubmodule) {
|
|
// We're done with this submodule.
|
|
// We're done with this submodule.
|
|
Module *M = LeaveSubmodule(/*ForPragma*/false);
|
|
Module *M = LeaveSubmodule(/*ForPragma*/false);
|
|
@@ -489,6 +495,11 @@ bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) {
|
|
PPCallbacks::ExitFile, FileType, ExitedFID);
|
|
PPCallbacks::ExitFile, FileType, ExitedFID);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Restore conditional stack from the preamble right after exiting from the
|
|
|
|
+ // predefines file.
|
|
|
|
+ if (ExitedFromPredefinesFile)
|
|
|
|
+ replayPreambleConditionalStack();
|
|
|
|
+
|
|
// Client should lex another token unless we generated an EOM.
|
|
// Client should lex another token unless we generated an EOM.
|
|
return LeavingSubmodule;
|
|
return LeavingSubmodule;
|
|
}
|
|
}
|