Serialization: Skip invalid decls during module serialization.

When `-enable-lazy-typecheck` is specified, serialization may be expected to
run on an AST containing invalid declarations since type checking may happen
on-demand, during serialization, in this mode. If the declarations that are
invalid are not skipped, then the compiler is likely to crash when attempting
to serialize them. Now, invalid declarations are skipped and an error is
emitted at the end of serialization to note that serialization failed.

Additionally, a new `-Rmodule-serialization` flag can be specified to request
more detailed information about module serialization failures. This would be
useful in a situation where lazy typechecking does not produce any diagnostic
for some reason, but module serialization fails and more information is
therefore required to debug.

Resolves rdar://123260476
This commit is contained in:
Allan Shortlidge
2024-02-19 14:31:24 -08:00
parent d4c54af247
commit 72da8f4e9c
9 changed files with 71 additions and 7 deletions

View File

@@ -1088,6 +1088,8 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
Opts.EnableModuleLoadingRemarks = Args.hasArg(OPT_remark_loading_module);
Opts.EnableModuleRecoveryRemarks = Args.hasArg(OPT_remark_module_recovery);
Opts.EnableModuleSerializationRemarks =
Args.hasArg(OPT_remark_module_serialization);
Opts.EnableModuleApiImportRemarks = Args.hasArg(OPT_remark_module_api_import);
Opts.EnableMacroLoadingRemarks = Args.hasArg(OPT_remark_macro_loading);
Opts.EnableIndexingSystemModuleRemarks = Args.hasArg(OPT_remark_indexing_system_module);