@@ -889,10 +889,8 @@ void CompilerInstance::finishTypeChecking() {
889
889
});
890
890
}
891
891
892
- SourceFile *CompilerInstance::createSourceFileForMainModule (
893
- SourceFileKind fileKind, Optional<unsigned > bufferID) {
894
- ModuleDecl *mainModule = getMainModule ();
895
-
892
+ SourceFile::ParsingOptions
893
+ CompilerInstance::getSourceFileParsingOptions (bool forPrimary) const {
896
894
const auto &frontendOpts = Invocation.getFrontendOptions ();
897
895
const auto action = frontendOpts.RequestedAction ;
898
896
@@ -912,9 +910,8 @@ SourceFile *CompilerInstance::createSourceFileForMainModule(
912
910
opts |= SourceFile::ParsingFlags::DisableDelayedBodies;
913
911
}
914
912
915
- auto isPrimary = bufferID && isPrimaryInput (*bufferID);
916
- if (isPrimary || isWholeModuleCompilation ()) {
917
- // Disable delayed body parsing for primaries.
913
+ if (forPrimary || isWholeModuleCompilation ()) {
914
+ // Disable delayed body parsing for primaries and in WMO.
918
915
opts |= SourceFile::ParsingFlags::DisableDelayedBodies;
919
916
} else {
920
917
// Suppress parse warnings for non-primaries, as they'll get parsed multiple
@@ -924,9 +921,18 @@ SourceFile *CompilerInstance::createSourceFileForMainModule(
924
921
925
922
// Enable interface hash computation for primaries, but not in WMO, as it's
926
923
// only currently needed for incremental mode.
927
- if (isPrimary ) {
924
+ if (forPrimary ) {
928
925
opts |= SourceFile::ParsingFlags::EnableInterfaceHash;
929
926
}
927
+ return opts;
928
+ }
929
+
930
+ SourceFile *CompilerInstance::createSourceFileForMainModule (
931
+ SourceFileKind fileKind, Optional<unsigned > bufferID) {
932
+ ModuleDecl *mainModule = getMainModule ();
933
+
934
+ auto isPrimary = bufferID && isPrimaryInput (*bufferID);
935
+ auto opts = getSourceFileParsingOptions (isPrimary);
930
936
931
937
auto *inputFile = new (*Context)
932
938
SourceFile (*mainModule, fileKind, bufferID, opts, isPrimary);
0 commit comments