[Serialization] Add an option to output modules regardless of errors

Adds a new frontend option
"-experimental-allow-module-with-compiler-errors". If any compilation
errors occur while generating the .swiftmodule, this mode will skip SIL
entirely and only serialize the (likey invalid) AST.

This existence of this option during generation is serialized into the
resulting .swiftmodule. Errors found in deserialization are only allowed
if it is set.

Primarily intended for IDE requests (eg. indexing and code completion)
to ensure robust cross-module results, despite possible errors.

Resolves rdar://69815975
This commit is contained in:
Ben Barham
2020-10-22 13:33:23 +10:00
parent b714a317e0
commit 241559dc88
21 changed files with 386 additions and 22 deletions

View File

@@ -145,6 +145,9 @@ static bool readOptionsBlock(llvm::BitstreamCursor &cursor,
options_block::ResilienceStrategyLayout::readRecord(scratch, Strategy);
extendedInfo.setResilienceStrategy(ResilienceStrategy(Strategy));
break;
case options_block::IS_ALLOW_MODULE_WITH_COMPILER_ERRORS_ENABLED:
extendedInfo.setAllowModuleWithCompilerErrorsEnabled(true);
break;
default:
// Unknown options record, possibly for use by a future version of the
// module format.
@@ -1150,6 +1153,8 @@ ModuleFileSharedCore::ModuleFileSharedCore(
Bits.IsTestable = extInfo.isTestable();
Bits.ResilienceStrategy = unsigned(extInfo.getResilienceStrategy());
Bits.IsImplicitDynamicEnabled = extInfo.isImplicitDynamicEnabled();
Bits.IsAllowModuleWithCompilerErrorsEnabled =
extInfo.isAllowModuleWithCompilerErrorsEnabled();
MiscVersion = info.miscVersion;
hasValidControlBlock = true;