@@ -1095,30 +1095,36 @@ void CompilerInstance::performParseOnly(bool EvaluateConditionals,
1095
1095
PersistentState = llvm::make_unique<PersistentParserState>();
1096
1096
PersistentState->PerformConditionEvaluation = EvaluateConditionals;
1097
1097
1098
+ auto shouldDelayBodies = [&](unsigned bufferID) -> bool {
1099
+ if (!CanDelayBodies)
1100
+ return false ;
1101
+
1102
+ // Don't delay bodies in whole module mode or for primary files.
1103
+ return !(isWholeModuleCompilation () || isPrimaryInput (bufferID));
1104
+ };
1105
+
1098
1106
// Parse all the library files.
1099
1107
for (auto BufferID : InputSourceCodeBufferIDs) {
1100
1108
if (BufferID == MainBufferID)
1101
1109
continue ;
1102
1110
1103
- auto IsPrimary = isWholeModuleCompilation () || isPrimaryInput (BufferID);
1104
-
1105
1111
SourceFile *NextInput = createSourceFileForMainModule (
1106
1112
SourceFileKind::Library, SourceFile::ImplicitModuleImportKind::None,
1107
1113
BufferID);
1108
1114
1109
1115
parseIntoSourceFileFull (*NextInput, BufferID, PersistentState.get (),
1110
- /* DelayBodyParsing= */ !IsPrimary && CanDelayBodies );
1116
+ shouldDelayBodies (BufferID) );
1111
1117
}
1112
1118
1113
1119
// Now parse the main file.
1114
1120
if (MainBufferID != NO_SUCH_BUFFER) {
1115
1121
SourceFile &MainFile =
1116
1122
MainModule->getMainSourceFile (Invocation.getSourceFileKind ());
1117
1123
MainFile.SyntaxParsingCache = Invocation.getMainFileSyntaxParsingCache ();
1124
+ assert (MainBufferID == MainFile.getBufferID ());
1118
1125
1119
- parseIntoSourceFileFull (MainFile, MainFile.getBufferID ().getValue (),
1120
- PersistentState.get (),
1121
- /* DelayBodyParsing=*/ false );
1126
+ parseIntoSourceFileFull (MainFile, MainBufferID, PersistentState.get (),
1127
+ shouldDelayBodies (MainBufferID));
1122
1128
}
1123
1129
1124
1130
assert (Context->LoadedModules .size () == 1 &&
0 commit comments