@@ -2064,19 +2064,6 @@ static lldb::ModuleSP GetUnitTestModule(lldb_private::ModuleList &modules) {
2064
2064
return ModuleSP ();
2065
2065
}
2066
2066
2067
- static SwiftASTContext *GetModuleSwiftASTContext (Module &module ) {
2068
- auto type_system_or_err =
2069
- module .GetTypeSystemForLanguage (lldb::eLanguageTypeSwift);
2070
- if (!type_system_or_err) {
2071
- llvm::consumeError (type_system_or_err.takeError ());
2072
- return {};
2073
- }
2074
- auto *ts = llvm::dyn_cast_or_null<TypeSystemSwift>(type_system_or_err->get ());
2075
- if (!ts)
2076
- return {};
2077
- return ts->GetSwiftASTContext ();
2078
- }
2079
-
2080
2067
// / Scan a newly added lldb::Module for Swift modules and report any errors in
2081
2068
// / its module SwiftASTContext to Target.
2082
2069
static void ProcessModule (
@@ -2313,10 +2300,7 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
2313
2300
auto get_executable_triple = [&]() -> llvm::Triple {
2314
2301
if (!exe_module_sp)
2315
2302
return {};
2316
- auto *exe_ast_ctx = GetModuleSwiftASTContext (*exe_module_sp);
2317
- if (!exe_ast_ctx)
2318
- return {};
2319
- return exe_ast_ctx->GetLanguageOptions ().Target ;
2303
+ return exe_module_sp->GetArchitecture ().GetTriple ();
2320
2304
};
2321
2305
2322
2306
llvm::Triple computed_triple;
@@ -2399,25 +2383,22 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
2399
2383
const bool use_all_compiler_flags =
2400
2384
!got_serialized_options || target.GetUseAllCompilerFlags ();
2401
2385
2402
- for (size_t mi = 0 ; mi != num_images; ++mi) {
2403
- std::vector<std::string> extra_clang_args;
2404
- ProcessModule (target.GetImages ().GetModuleAtIndex (mi), m_description,
2405
- discover_implicit_search_paths, use_all_compiler_flags,
2406
- target, triple, plugin_search_options, module_search_paths,
2407
- framework_search_paths, extra_clang_args);
2408
- swift_ast_sp->AddExtraClangArgs (extra_clang_args);
2409
- }
2386
+ for (ModuleSP module_sp : target.GetImages ().Modules ())
2387
+ if (module_sp) {
2388
+ std::vector<std::string> extra_clang_args;
2389
+ ProcessModule (module_sp, m_description, discover_implicit_search_paths,
2390
+ use_all_compiler_flags, target, triple,
2391
+ plugin_search_options, module_search_paths,
2392
+ framework_search_paths, extra_clang_args);
2393
+ swift_ast_sp->AddExtraClangArgs (extra_clang_args);
2394
+ }
2410
2395
2411
- FileSpecList target_module_paths = target.GetSwiftModuleSearchPaths ();
2412
- for (size_t mi = 0 , me = target_module_paths.GetSize (); mi != me; ++mi)
2413
- module_search_paths.push_back (
2414
- target_module_paths.GetFileSpecAtIndex (mi).GetPath ());
2396
+ for (const FileSpec &path : target.GetSwiftModuleSearchPaths ())
2397
+ module_search_paths.push_back (path.GetPath ());
2415
2398
2416
- FileSpecList target_framework_paths = target.GetSwiftFrameworkSearchPaths ();
2417
- for (size_t fi = 0 , fe = target_framework_paths.GetSize (); fi != fe; ++fi)
2418
- framework_search_paths.push_back (
2419
- {target_framework_paths.GetFileSpecAtIndex (fi).GetPath (),
2420
- /* is_system*/ false });
2399
+ for (const FileSpec &path : target.GetSwiftFrameworkSearchPaths ())
2400
+ framework_search_paths.push_back ({path.GetPath (),
2401
+ /* is_system*/ false });
2421
2402
2422
2403
// Now fold any extra options we were passed. This has to be done
2423
2404
// BEFORE the ClangImporter is made by calling GetClangImporter or
@@ -2437,6 +2418,11 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
2437
2418
2438
2419
swift_ast_sp->ApplyDiagnosticOptions ();
2439
2420
2421
+ // Apply source path remappings found in each module's dSYM.
2422
+ for (ModuleSP module : target.GetImages ().Modules ())
2423
+ if (module )
2424
+ swift_ast_sp->RemapClangImporterOptions (module ->GetSourceMappingList ());
2425
+
2440
2426
// Apply source path remappings found in the target settings.
2441
2427
swift_ast_sp->RemapClangImporterOptions (target.GetSourcePathMap ());
2442
2428
swift_ast_sp->FilterClangImporterOptions (
0 commit comments