@@ -2015,50 +2015,6 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(lldb::LanguageType language,
2015
2015
pool.wait ();
2016
2016
}
2017
2017
2018
- for (size_t mi = 0 ; mi != num_images; ++mi) {
2019
- ModuleSP module_sp = target.GetImages ().GetModuleAtIndex (mi);
2020
-
2021
- // Skip images without a serialized Swift AST. This avoids
2022
- // spurious warning messages.
2023
- if (!HasSwiftModules (*module_sp))
2024
- continue ;
2025
-
2026
- auto type_system_or_err =
2027
- module_sp->GetTypeSystemForLanguage (lldb::eLanguageTypeSwift);
2028
- if (!type_system_or_err) {
2029
- llvm::consumeError (type_system_or_err.takeError ());
2030
- continue ;
2031
- }
2032
-
2033
- auto *module_swift_ast =
2034
- llvm::dyn_cast_or_null<SwiftASTContext>(&*type_system_or_err);
2035
- if (module_swift_ast && !module_swift_ast->HasFatalErrors () &&
2036
- module_swift_ast->GetClangImporter ())
2037
- continue ;
2038
- // Make sure we warn about this module load failure, the one
2039
- // that comes from loading types often gets swallowed up and not
2040
- // seen, this is the only reliable point where we can show this.
2041
- // But only do it once per UUID so we don't overwhelm the user
2042
- // with warnings.
2043
- UUID module_uuid (module_sp->GetUUID ());
2044
- bool unique_message =
2045
- target.RegisterSwiftContextMessageKey (module_uuid.GetAsString ());
2046
- if (!unique_message)
2047
- continue ;
2048
- std::string buf;
2049
- {
2050
- llvm::raw_string_ostream ss (buf);
2051
- module_sp->GetDescription (ss, eDescriptionLevelBrief);
2052
- if (module_swift_ast && module_swift_ast->HasFatalErrors ())
2053
- ss << " : "
2054
- << module_swift_ast->GetFatalErrors ().AsCString (" unknown error" );
2055
- }
2056
- target.GetDebugger ().GetErrorStreamSP ()->Printf (
2057
- " Error while loading Swift module:\n %s\n "
2058
- " Debug info from this module will be unavailable in the debugger.\n\n " ,
2059
- buf.c_str ());
2060
- }
2061
-
2062
2018
if (!handled_sdk_path) {
2063
2019
for (size_t mi = 0 ; mi != num_images; ++mi) {
2064
2020
ModuleSP module_sp = target.GetImages ().GetModuleAtIndex (mi);
@@ -2259,7 +2215,36 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(lldb::LanguageType language,
2259
2215
2260
2216
SwiftASTContext *ast_context =
2261
2217
llvm::dyn_cast_or_null<SwiftASTContext>(&*type_system_or_err);
2262
- if (ast_context && !ast_context->HasErrors ()) {
2218
+
2219
+ if (!ast_context || ast_context->HasFatalErrors () ||
2220
+ !ast_context->GetClangImporter ()) {
2221
+ // Make sure we warn about this module load failure, the one
2222
+ // that comes from loading types often gets swallowed up and not
2223
+ // seen, this is the only reliable point where we can show this.
2224
+ // But only do it once per UUID so we don't overwhelm the user
2225
+ // with warnings.
2226
+ UUID module_uuid (module_sp->GetUUID ());
2227
+ bool unique_message =
2228
+ target.RegisterSwiftContextMessageKey (module_uuid.GetAsString ());
2229
+ if (!unique_message)
2230
+ return ;
2231
+ std::string buf;
2232
+ {
2233
+ llvm::raw_string_ostream ss (buf);
2234
+ module_sp->GetDescription (ss, eDescriptionLevelBrief);
2235
+ if (ast_context && ast_context->HasFatalErrors ())
2236
+ ss << " : "
2237
+ << ast_context->GetFatalErrors ().AsCString (" unknown error" );
2238
+ }
2239
+ target.GetDebugger ().GetErrorStreamSP ()->Printf (
2240
+ " Error while loading Swift module:\n %s\n "
2241
+ " Debug info from this module will be unavailable in the "
2242
+ " debugger.\n\n " ,
2243
+ buf.c_str ());
2244
+ return ;
2245
+ }
2246
+
2247
+ if (!ast_context->HasErrors ()) {
2263
2248
if (use_all_compiler_flags ||
2264
2249
target.GetExecutableModulePointer () == module_sp.get ()) {
2265
2250
0 commit comments