Skip to content

Commit 377a502

Browse files
authored
Merge pull request #3766 from ahoppen/pr/cherry-pick-module-search-path-getter-next
[lldb] Use getters to retrieve Swift module search paths
2 parents c804611 + 1162876 commit 377a502

File tree

1 file changed

+35
-23
lines changed

1 file changed

+35
-23
lines changed

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

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2102,9 +2102,9 @@ ProcessModule(ModuleSP module_sp, std::string m_description,
21022102

21032103
const auto &opts = invocation.getSearchPathOptions();
21042104
module_search_paths.insert(module_search_paths.end(),
2105-
opts.ImportSearchPaths.begin(),
2106-
opts.ImportSearchPaths.end());
2107-
for (const auto &fwsp : opts.FrameworkSearchPaths)
2105+
opts.getImportSearchPaths().begin(),
2106+
opts.getImportSearchPaths().end());
2107+
for (const auto &fwsp : opts.getFrameworkSearchPaths())
21082108
framework_search_paths.push_back({fwsp.Path, fwsp.IsSystem});
21092109
auto &clang_opts = invocation.getClangImporterOptions().ExtraArgs;
21102110
for (const std::string &arg : clang_opts) {
@@ -2685,8 +2685,8 @@ void SwiftASTContext::InitializeSearchPathOptions(
26852685
}
26862686

26872687
llvm::StringMap<bool> processed;
2688-
std::vector<std::string> &invocation_import_paths =
2689-
invocation.getSearchPathOptions().ImportSearchPaths;
2688+
std::vector<std::string> invocation_import_paths(
2689+
invocation.getSearchPathOptions().getImportSearchPaths());
26902690
// Add all deserialized paths to the map.
26912691
for (const auto &path : invocation_import_paths)
26922692
processed.insert({path, false});
@@ -2697,11 +2697,14 @@ void SwiftASTContext::InitializeSearchPathOptions(
26972697
if (it_notseen.second)
26982698
invocation_import_paths.push_back(path);
26992699
}
2700+
invocation.getSearchPathOptions().setImportSearchPaths(
2701+
invocation_import_paths);
27002702

27012703
// This preserves the IsSystem bit, but deduplicates entries ignoring it.
27022704
processed.clear();
2703-
auto &invocation_framework_paths =
2704-
invocation.getSearchPathOptions().FrameworkSearchPaths;
2705+
std::vector<swift::SearchPathOptions::FrameworkSearchPath>
2706+
invocation_framework_paths(
2707+
invocation.getSearchPathOptions().getFrameworkSearchPaths());
27052708
// Add all deserialized paths to the map.
27062709
for (const auto &path : invocation_framework_paths)
27072710
processed.insert({path.Path, path.IsSystem});
@@ -2712,6 +2715,8 @@ void SwiftASTContext::InitializeSearchPathOptions(
27122715
if (it_notseen.second)
27132716
invocation_framework_paths.push_back({path.first, path.second});
27142717
}
2718+
invocation.getSearchPathOptions().setFrameworkSearchPaths(
2719+
invocation_framework_paths);
27152720
}
27162721

27172722
namespace lldb_private {
@@ -3373,7 +3378,8 @@ swift::ASTContext *SwiftASTContext::GetASTContext() {
33733378
std::string moduleCachePath = "";
33743379
std::unique_ptr<swift::ClangImporter> clang_importer_ap;
33753380
auto &clang_importer_options = GetClangImporterOptions();
3376-
if (!m_ast_context_ap->SearchPathOpts.SDKPath.empty() || TargetHasNoSDK()) {
3381+
if (!m_ast_context_ap->SearchPathOpts.getSDKPath().empty() ||
3382+
TargetHasNoSDK()) {
33773383
if (!clang_importer_options.OverrideResourceDir.empty()) {
33783384
// Create the DWARFImporterDelegate.
33793385
const auto &props = ModuleList::GetGlobalModuleListProperties();
@@ -3431,7 +3437,7 @@ swift::ASTContext *SwiftASTContext::GetASTContext() {
34313437
if (!sdk_version) {
34323438
auto SDKInfoOrErr = clang::parseDarwinSDKInfo(
34333439
*llvm::vfs::getRealFileSystem(),
3434-
m_ast_context_ap->SearchPathOpts.SDKPath);
3440+
m_ast_context_ap->SearchPathOpts.getSDKPath());
34353441
if (SDKInfoOrErr) {
34363442
if (auto SDKInfo = *SDKInfoOrErr)
34373443
sdk_version = swift::getTargetSDKVersion(*SDKInfo, triple);
@@ -3732,16 +3738,17 @@ swift::ModuleDecl *SwiftASTContext::GetModule(const FileSpec &module_spec,
37323738

37333739
std::string module_directory(module_spec.GetDirectory().GetCString());
37343740
bool add_search_path = true;
3735-
for (auto path : ast->SearchPathOpts.ImportSearchPaths) {
3741+
for (auto path : ast->SearchPathOpts.getImportSearchPaths()) {
37363742
if (path == module_directory) {
37373743
add_search_path = false;
37383744
break;
37393745
}
37403746
}
37413747
// Add the search path if needed so we can find the module by basename.
3742-
if (add_search_path)
3743-
ast->SearchPathOpts.ImportSearchPaths.push_back(
3744-
std::move(module_directory));
3748+
if (add_search_path) {
3749+
ast->addSearchPath(module_directory, /*isFramework=*/false,
3750+
/*isSystem=*/false);
3751+
}
37453752

37463753
typedef swift::Located<swift::Identifier> ModuleNameSpec;
37473754
llvm::StringRef module_basename_sref(module_basename.GetCString());
@@ -3940,7 +3947,8 @@ void SwiftASTContext::LoadModule(swift::ModuleDecl *swift_module,
39403947
std::vector<std::string> uniqued_paths;
39413948

39423949
for (const auto &framework_search_dir :
3943-
swift_module->getASTContext().SearchPathOpts.FrameworkSearchPaths) {
3950+
swift_module->getASTContext()
3951+
.SearchPathOpts.getFrameworkSearchPaths()) {
39443952
// The framework search dir as it comes from the AST context
39453953
// often has duplicate entries, don't try to load along the
39463954
// same path twice.
@@ -5138,8 +5146,9 @@ void SwiftASTContext::LogConfiguration() {
51385146

51395147
HEALTH_LOG_PRINTF(" Architecture : %s",
51405148
m_ast_context_ap->LangOpts.Target.getTriple().c_str());
5141-
HEALTH_LOG_PRINTF(" SDK path : %s",
5142-
m_ast_context_ap->SearchPathOpts.SDKPath.c_str());
5149+
HEALTH_LOG_PRINTF(
5150+
" SDK path : %s",
5151+
m_ast_context_ap->SearchPathOpts.getSDKPath().str().c_str());
51435152
HEALTH_LOG_PRINTF(
51445153
" Runtime resource path : %s",
51455154
m_ast_context_ap->SearchPathOpts.RuntimeResourcePath.c_str());
@@ -5154,26 +5163,29 @@ void SwiftASTContext::LogConfiguration() {
51545163

51555164
HEALTH_LOG_PRINTF(" Runtime library import paths : (%llu items)",
51565165
(unsigned long long)m_ast_context_ap->SearchPathOpts
5157-
.RuntimeLibraryImportPaths.size());
5166+
.getRuntimeLibraryImportPaths()
5167+
.size());
51585168

51595169
for (const auto &runtime_import_path :
5160-
m_ast_context_ap->SearchPathOpts.RuntimeLibraryImportPaths) {
5170+
m_ast_context_ap->SearchPathOpts.getRuntimeLibraryImportPaths()) {
51615171
HEALTH_LOG_PRINTF(" %s", runtime_import_path.c_str());
51625172
}
51635173

51645174
HEALTH_LOG_PRINTF(" Framework search paths : (%llu items)",
51655175
(unsigned long long)m_ast_context_ap->SearchPathOpts
5166-
.FrameworkSearchPaths.size());
5176+
.getFrameworkSearchPaths()
5177+
.size());
51675178
for (const auto &framework_search_path :
5168-
m_ast_context_ap->SearchPathOpts.FrameworkSearchPaths) {
5179+
m_ast_context_ap->SearchPathOpts.getFrameworkSearchPaths()) {
51695180
HEALTH_LOG_PRINTF(" %s", framework_search_path.Path.c_str());
51705181
}
51715182

51725183
HEALTH_LOG_PRINTF(" Import search paths : (%llu items)",
51735184
(unsigned long long)m_ast_context_ap->SearchPathOpts
5174-
.ImportSearchPaths.size());
5175-
for (std::string &import_search_path :
5176-
m_ast_context_ap->SearchPathOpts.ImportSearchPaths) {
5185+
.getImportSearchPaths()
5186+
.size());
5187+
for (const std::string &import_search_path :
5188+
m_ast_context_ap->SearchPathOpts.getImportSearchPaths()) {
51775189
HEALTH_LOG_PRINTF(" %s", import_search_path.c_str());
51785190
}
51795191

0 commit comments

Comments
 (0)