Skip to content

Commit 43f7de5

Browse files
authored
Merge pull request #3546 from ahoppen/pr/search-path-getters
[lldb] Use getters to retrieve Swift module search paths
2 parents 8647a7a + e87c62d commit 43f7de5

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
@@ -2091,9 +2091,9 @@ ProcessModule(ModuleSP module_sp, std::string m_description,
20912091

20922092
const auto &opts = invocation.getSearchPathOptions();
20932093
module_search_paths.insert(module_search_paths.end(),
2094-
opts.ImportSearchPaths.begin(),
2095-
opts.ImportSearchPaths.end());
2096-
for (const auto &fwsp : opts.FrameworkSearchPaths)
2094+
opts.getImportSearchPaths().begin(),
2095+
opts.getImportSearchPaths().end());
2096+
for (const auto &fwsp : opts.getFrameworkSearchPaths())
20972097
framework_search_paths.push_back({fwsp.Path, fwsp.IsSystem});
20982098
auto &clang_opts = invocation.getClangImporterOptions().ExtraArgs;
20992099
for (const std::string &arg : clang_opts) {
@@ -2674,8 +2674,8 @@ void SwiftASTContext::InitializeSearchPathOptions(
26742674
}
26752675

26762676
llvm::StringMap<bool> processed;
2677-
std::vector<std::string> &invocation_import_paths =
2678-
invocation.getSearchPathOptions().ImportSearchPaths;
2677+
std::vector<std::string> invocation_import_paths(
2678+
invocation.getSearchPathOptions().getImportSearchPaths());
26792679
// Add all deserialized paths to the map.
26802680
for (const auto &path : invocation_import_paths)
26812681
processed.insert({path, false});
@@ -2686,11 +2686,14 @@ void SwiftASTContext::InitializeSearchPathOptions(
26862686
if (it_notseen.second)
26872687
invocation_import_paths.push_back(path);
26882688
}
2689+
invocation.getSearchPathOptions().setImportSearchPaths(
2690+
invocation_import_paths);
26892691

26902692
// This preserves the IsSystem bit, but deduplicates entries ignoring it.
26912693
processed.clear();
2692-
auto &invocation_framework_paths =
2693-
invocation.getSearchPathOptions().FrameworkSearchPaths;
2694+
std::vector<swift::SearchPathOptions::FrameworkSearchPath>
2695+
invocation_framework_paths(
2696+
invocation.getSearchPathOptions().getFrameworkSearchPaths());
26942697
// Add all deserialized paths to the map.
26952698
for (const auto &path : invocation_framework_paths)
26962699
processed.insert({path.Path, path.IsSystem});
@@ -2701,6 +2704,8 @@ void SwiftASTContext::InitializeSearchPathOptions(
27012704
if (it_notseen.second)
27022705
invocation_framework_paths.push_back({path.first, path.second});
27032706
}
2707+
invocation.getSearchPathOptions().setFrameworkSearchPaths(
2708+
invocation_framework_paths);
27042709
}
27052710

27062711
namespace lldb_private {
@@ -3362,7 +3367,8 @@ swift::ASTContext *SwiftASTContext::GetASTContext() {
33623367
std::string moduleCachePath = "";
33633368
std::unique_ptr<swift::ClangImporter> clang_importer_ap;
33643369
auto &clang_importer_options = GetClangImporterOptions();
3365-
if (!m_ast_context_ap->SearchPathOpts.SDKPath.empty() || TargetHasNoSDK()) {
3370+
if (!m_ast_context_ap->SearchPathOpts.getSDKPath().empty() ||
3371+
TargetHasNoSDK()) {
33663372
if (!clang_importer_options.OverrideResourceDir.empty()) {
33673373
// Create the DWARFImporterDelegate.
33683374
const auto &props = ModuleList::GetGlobalModuleListProperties();
@@ -3420,7 +3426,7 @@ swift::ASTContext *SwiftASTContext::GetASTContext() {
34203426
if (!sdk_version) {
34213427
auto SDKInfoOrErr = clang::parseDarwinSDKInfo(
34223428
*llvm::vfs::getRealFileSystem(),
3423-
m_ast_context_ap->SearchPathOpts.SDKPath);
3429+
m_ast_context_ap->SearchPathOpts.getSDKPath());
34243430
if (SDKInfoOrErr) {
34253431
if (auto SDKInfo = *SDKInfoOrErr)
34263432
sdk_version = swift::getTargetSDKVersion(*SDKInfo, triple);
@@ -3721,16 +3727,17 @@ swift::ModuleDecl *SwiftASTContext::GetModule(const FileSpec &module_spec,
37213727

37223728
std::string module_directory(module_spec.GetDirectory().GetCString());
37233729
bool add_search_path = true;
3724-
for (auto path : ast->SearchPathOpts.ImportSearchPaths) {
3730+
for (auto path : ast->SearchPathOpts.getImportSearchPaths()) {
37253731
if (path == module_directory) {
37263732
add_search_path = false;
37273733
break;
37283734
}
37293735
}
37303736
// Add the search path if needed so we can find the module by basename.
3731-
if (add_search_path)
3732-
ast->SearchPathOpts.ImportSearchPaths.push_back(
3733-
std::move(module_directory));
3737+
if (add_search_path) {
3738+
ast->addSearchPath(module_directory, /*isFramework=*/false,
3739+
/*isSystem=*/false);
3740+
}
37343741

37353742
typedef swift::Located<swift::Identifier> ModuleNameSpec;
37363743
llvm::StringRef module_basename_sref(module_basename.GetCString());
@@ -3929,7 +3936,8 @@ void SwiftASTContext::LoadModule(swift::ModuleDecl *swift_module,
39293936
std::vector<std::string> uniqued_paths;
39303937

39313938
for (const auto &framework_search_dir :
3932-
swift_module->getASTContext().SearchPathOpts.FrameworkSearchPaths) {
3939+
swift_module->getASTContext()
3940+
.SearchPathOpts.getFrameworkSearchPaths()) {
39333941
// The framework search dir as it comes from the AST context
39343942
// often has duplicate entries, don't try to load along the
39353943
// same path twice.
@@ -5127,8 +5135,9 @@ void SwiftASTContext::LogConfiguration() {
51275135

51285136
HEALTH_LOG_PRINTF(" Architecture : %s",
51295137
m_ast_context_ap->LangOpts.Target.getTriple().c_str());
5130-
HEALTH_LOG_PRINTF(" SDK path : %s",
5131-
m_ast_context_ap->SearchPathOpts.SDKPath.c_str());
5138+
HEALTH_LOG_PRINTF(
5139+
" SDK path : %s",
5140+
m_ast_context_ap->SearchPathOpts.getSDKPath().str().c_str());
51325141
HEALTH_LOG_PRINTF(
51335142
" Runtime resource path : %s",
51345143
m_ast_context_ap->SearchPathOpts.RuntimeResourcePath.c_str());
@@ -5143,26 +5152,29 @@ void SwiftASTContext::LogConfiguration() {
51435152

51445153
HEALTH_LOG_PRINTF(" Runtime library import paths : (%llu items)",
51455154
(unsigned long long)m_ast_context_ap->SearchPathOpts
5146-
.RuntimeLibraryImportPaths.size());
5155+
.getRuntimeLibraryImportPaths()
5156+
.size());
51475157

51485158
for (const auto &runtime_import_path :
5149-
m_ast_context_ap->SearchPathOpts.RuntimeLibraryImportPaths) {
5159+
m_ast_context_ap->SearchPathOpts.getRuntimeLibraryImportPaths()) {
51505160
HEALTH_LOG_PRINTF(" %s", runtime_import_path.c_str());
51515161
}
51525162

51535163
HEALTH_LOG_PRINTF(" Framework search paths : (%llu items)",
51545164
(unsigned long long)m_ast_context_ap->SearchPathOpts
5155-
.FrameworkSearchPaths.size());
5165+
.getFrameworkSearchPaths()
5166+
.size());
51565167
for (const auto &framework_search_path :
5157-
m_ast_context_ap->SearchPathOpts.FrameworkSearchPaths) {
5168+
m_ast_context_ap->SearchPathOpts.getFrameworkSearchPaths()) {
51585169
HEALTH_LOG_PRINTF(" %s", framework_search_path.Path.c_str());
51595170
}
51605171

51615172
HEALTH_LOG_PRINTF(" Import search paths : (%llu items)",
51625173
(unsigned long long)m_ast_context_ap->SearchPathOpts
5163-
.ImportSearchPaths.size());
5164-
for (std::string &import_search_path :
5165-
m_ast_context_ap->SearchPathOpts.ImportSearchPaths) {
5174+
.getImportSearchPaths()
5175+
.size());
5176+
for (const std::string &import_search_path :
5177+
m_ast_context_ap->SearchPathOpts.getImportSearchPaths()) {
51665178
HEALTH_LOG_PRINTF(" %s", import_search_path.c_str());
51675179
}
51685180

0 commit comments

Comments
 (0)