Skip to content

Commit ca58189

Browse files
committed
Apply dSYM path remapping dictionary also to the expression context.
This fixes an oversight that was uncovered by making it less likely to instantiate a per-module SwiftASTContext.
1 parent b29780e commit ca58189

File tree

2 files changed

+21
-28
lines changed

2 files changed

+21
-28
lines changed

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2383,25 +2383,22 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
23832383
const bool use_all_compiler_flags =
23842384
!got_serialized_options || target.GetUseAllCompilerFlags();
23852385

2386-
for (size_t mi = 0; mi != num_images; ++mi) {
2387-
std::vector<std::string> extra_clang_args;
2388-
ProcessModule(target.GetImages().GetModuleAtIndex(mi), m_description,
2389-
discover_implicit_search_paths, use_all_compiler_flags,
2390-
target, triple, plugin_search_options, module_search_paths,
2391-
framework_search_paths, extra_clang_args);
2392-
swift_ast_sp->AddExtraClangArgs(extra_clang_args);
2393-
}
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+
}
23942395

2395-
FileSpecList target_module_paths = target.GetSwiftModuleSearchPaths();
2396-
for (size_t mi = 0, me = target_module_paths.GetSize(); mi != me; ++mi)
2397-
module_search_paths.push_back(
2398-
target_module_paths.GetFileSpecAtIndex(mi).GetPath());
2396+
for (const FileSpec &path : target.GetSwiftModuleSearchPaths())
2397+
module_search_paths.push_back(path.GetPath());
23992398

2400-
FileSpecList target_framework_paths = target.GetSwiftFrameworkSearchPaths();
2401-
for (size_t fi = 0, fe = target_framework_paths.GetSize(); fi != fe; ++fi)
2402-
framework_search_paths.push_back(
2403-
{target_framework_paths.GetFileSpecAtIndex(fi).GetPath(),
2404-
/*is_system*/ false});
2399+
for (const FileSpec &path : target.GetSwiftFrameworkSearchPaths())
2400+
framework_search_paths.push_back({path.GetPath(),
2401+
/*is_system*/ false});
24052402

24062403
// Now fold any extra options we were passed. This has to be done
24072404
// BEFORE the ClangImporter is made by calling GetClangImporter or
@@ -2421,6 +2418,11 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
24212418

24222419
swift_ast_sp->ApplyDiagnosticOptions();
24232420

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+
24242426
// Apply source path remappings found in the target settings.
24252427
swift_ast_sp->RemapClangImporterOptions(target.GetSourcePathMap());
24262428
swift_ast_sp->FilterClangImporterOptions(

lldb/test/API/lang/swift/clangimporter/remap_sdk_path/TestSwiftRemapSDKPath.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,5 @@ def test(self):
2424
self.expect("expression 1", substrs=["1"])
2525

2626
# Scan through the types log.
27-
import io
28-
29-
logfile = io.open(log, "r", encoding="utf-8")
30-
found = 0
31-
for line in logfile:
32-
if line.startswith(
33-
' SwiftASTContextForModule("a.out")::RemapClangImporterOptions() -- remapped'
34-
):
35-
if "/LocalSDK/" in line:
36-
found += 1
37-
self.assertEqual(found, 1)
27+
self.filecheck('platform shell cat "%s"' % log, __file__)
28+
# CHECK: SwiftASTContextForExpressions::RemapClangImporterOptions() -- remapped{{.*}}/LocalSDK/

0 commit comments

Comments
 (0)