Skip to content

Commit 619b819

Browse files
[lldb] Adjust to swift::SearchPathOptions enhancing the ImportSearchPaths type
swift::SearchPathOptions renamed FrameworkSearchPath to SearchPath and uses it for both ImportSearchPaths and FrameworkSearchPaths. rdar://141967997
1 parent 9f6c3d7 commit 619b819

File tree

2 files changed

+33
-30
lines changed

2 files changed

+33
-30
lines changed

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

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,9 +1312,10 @@ static bool DeserializeAllCompilerFlags(swift::CompilerInvocation &invocation,
13121312
known_##NAME.insert(path KEY); \
13131313
}
13141314

1315-
INIT_SEARCH_PATH_SET(std::string, getImportSearchPaths(),
1316-
import_search_paths, );
1317-
INIT_SEARCH_PATH_SET(swift::SearchPathOptions::FrameworkSearchPath,
1315+
INIT_SEARCH_PATH_SET(swift::SearchPathOptions::SearchPath,
1316+
getImportSearchPaths(), import_search_paths,
1317+
.Path);
1318+
INIT_SEARCH_PATH_SET(swift::SearchPathOptions::SearchPath,
13181319
getFrameworkSearchPaths(), framework_search_paths,
13191320
.Path);
13201321

@@ -1398,10 +1399,12 @@ static bool DeserializeAllCompilerFlags(swift::CompilerInvocation &invocation,
13981399
for (auto &searchPath : searchPaths) {
13991400
std::string path = remap(searchPath.Path);
14001401
if (!searchPath.IsFramework) {
1402+
swift::SearchPathOptions::SearchPath
1403+
import_search_path(path, searchPath.IsSystem);
14011404
if (known_import_search_paths.insert(path).second)
1402-
import_search_paths.push_back(path);
1405+
import_search_paths.push_back(import_search_path);
14031406
} else {
1404-
swift::SearchPathOptions::FrameworkSearchPath
1407+
swift::SearchPathOptions::SearchPath
14051408
framework_search_path(path, searchPath.IsSystem);
14061409
if (known_framework_search_paths.insert(path).second)
14071410
framework_search_paths.push_back(framework_search_path);
@@ -1801,7 +1804,7 @@ static void applyOverrideOptions(std::vector<std::string> &args,
18011804

18021805
void SwiftASTContext::AddExtraClangArgs(
18031806
const std::vector<std::string> &ExtraArgs,
1804-
const std::vector<std::string> &module_search_paths,
1807+
const std::vector<std::pair<std::string, bool>> module_search_paths,
18051808
const std::vector<std::pair<std::string, bool>> framework_search_paths,
18061809
StringRef overrideOpts) {
18071810
swift::ClangImporterOptions &importer_options = GetClangImporterOptions();
@@ -1850,7 +1853,7 @@ void SwiftASTContext::AddExtraClangArgs(
18501853

18511854
void SwiftASTContext::AddExtraClangCC1Args(
18521855
const std::vector<std::string> &source,
1853-
const std::vector<std::string> &module_search_paths,
1856+
const std::vector<std::pair<std::string, bool>> module_search_paths,
18541857
const std::vector<std::pair<std::string, bool>> framework_search_paths,
18551858
std::vector<std::string> &dest) {
18561859
clang::CompilerInvocation invocation;
@@ -1871,7 +1874,7 @@ void SwiftASTContext::AddExtraClangCC1Args(
18711874
// additional clang modules when doing type reconstruction.
18721875
for (auto &path : module_search_paths) {
18731876
clangArgs.push_back("-I");
1874-
clangArgs.push_back(path.c_str());
1877+
clangArgs.push_back(path.first.c_str());
18751878
}
18761879
for (auto &path : default_paths) {
18771880
llvm::SmallString<128> search_path(GetPlatformSDKPath());
@@ -2204,7 +2207,7 @@ ProcessModule(Module &module, std::string m_description,
22042207
bool is_main_executable, StringRef module_filter,
22052208
llvm::Triple triple,
22062209
std::vector<swift::PluginSearchOption> &plugin_search_options,
2207-
std::vector<std::string> &module_search_paths,
2210+
std::vector<std::pair<std::string, bool>> &module_search_paths,
22082211
std::vector<std::pair<std::string, bool>> &framework_search_paths,
22092212
std::vector<std::string> &extra_clang_args,
22102213
std::string &error) {
@@ -2301,7 +2304,7 @@ ProcessModule(Module &module, std::string m_description,
23012304
bool exists = false;
23022305
llvm::sys::fs::is_directory(path, exists);
23032306
if (exists)
2304-
module_search_paths.push_back(std::string(path));
2307+
module_search_paths.push_back({std::string(path), /*system*/ false});
23052308
}
23062309

23072310
// Create a one-off CompilerInvocation as a place to load the
@@ -2334,9 +2337,8 @@ ProcessModule(Module &module, std::string m_description,
23342337
plugin_search_options.insert(plugin_search_options.end(),
23352338
opts.PluginSearchOpts.begin(),
23362339
opts.PluginSearchOpts.end());
2337-
module_search_paths.insert(module_search_paths.end(),
2338-
opts.getImportSearchPaths().begin(),
2339-
opts.getImportSearchPaths().end());
2340+
for (auto path : opts.getImportSearchPaths())
2341+
module_search_paths.push_back({path.Path, path.IsSystem});
23402342
for (auto path : opts.getFrameworkSearchPaths())
23412343
framework_search_paths.push_back({path.Path, path.IsSystem});
23422344
auto &clang_opts = invocation.getClangImporterOptions().ExtraArgs;
@@ -2373,7 +2375,7 @@ SwiftASTContext::CreateInstance(lldb::LanguageType language, Module &module,
23732375
ss << '"' << ')';
23742376
}
23752377
LLDB_SCOPED_TIMERF("%s::CreateInstance", m_description.c_str());
2376-
std::vector<std::string> module_search_paths;
2378+
std::vector<std::pair<std::string, bool>> module_search_paths;
23772379
std::vector<std::pair<std::string, bool>> framework_search_paths;
23782380

23792381
LOG_PRINTF(GetLog(LLDBLog::Types), "(Module)");
@@ -3025,7 +3027,7 @@ SwiftASTContext::CreateInstance(const SymbolContext &sc,
30253027
ConfigureModuleCachePath(*swift_ast_sp);
30263028

30273029
std::vector<swift::PluginSearchOption> plugin_search_options;
3028-
std::vector<std::string> module_search_paths;
3030+
std::vector<std::pair<std::string, bool>> module_search_paths;
30293031
std::vector<std::pair<std::string, bool>> framework_search_paths;
30303032
std::vector<std::string> extra_clang_args;
30313033

@@ -3037,10 +3039,11 @@ SwiftASTContext::CreateInstance(const SymbolContext &sc,
30373039
use_all_compiler_flags =
30383040
!got_serialized_options || target_sp->GetUseAllCompilerFlags();
30393041

3042+
const bool is_system = false;
3043+
30403044
for (const FileSpec &path : target_sp->GetSwiftModuleSearchPaths())
3041-
module_search_paths.push_back(path.GetPath());
3045+
module_search_paths.push_back({path.GetPath(), is_system});
30423046

3043-
const bool is_system = false;
30443047
for (const FileSpec &path : target_sp->GetSwiftFrameworkSearchPaths())
30453048
framework_search_paths.push_back({path.GetPath(), is_system});
30463049
}
@@ -3528,7 +3531,7 @@ swift::SearchPathOptions &SwiftASTContext::GetSearchPathOptions() {
35283531
}
35293532

35303533
void SwiftASTContext::InitializeSearchPathOptions(
3531-
llvm::ArrayRef<std::string> extra_module_search_paths,
3534+
llvm::ArrayRef<std::pair<std::string, bool>> extra_module_search_paths,
35323535
llvm::ArrayRef<std::pair<std::string, bool>> extra_framework_search_paths) {
35333536
LLDB_SCOPED_TIMER();
35343537
swift::CompilerInvocation &invocation = GetCompilerInvocation();
@@ -3607,24 +3610,24 @@ void SwiftASTContext::InitializeSearchPathOptions(
36073610
}
36083611

36093612
llvm::StringMap<bool> processed;
3610-
std::vector<std::string> invocation_import_paths(
3613+
std::vector<swift::SearchPathOptions::SearchPath> invocation_import_paths(
36113614
invocation.getSearchPathOptions().getImportSearchPaths());
36123615
// Add all deserialized paths to the map.
36133616
for (const auto &path : invocation_import_paths)
3614-
processed.insert({path, false});
3617+
processed.insert({path.Path, path.IsSystem});
36153618

36163619
// Add/unique all extra paths.
36173620
for (const auto &path : extra_module_search_paths) {
3618-
auto it_notseen = processed.insert({path, false});
3621+
auto it_notseen = processed.insert(path);
36193622
if (it_notseen.second)
3620-
invocation_import_paths.push_back(path);
3623+
invocation_import_paths.push_back({path.first, path.second});
36213624
}
36223625
invocation.getSearchPathOptions().setImportSearchPaths(
36233626
invocation_import_paths);
36243627

36253628
// This preserves the IsSystem bit, but deduplicates entries ignoring it.
36263629
processed.clear();
3627-
std::vector<swift::SearchPathOptions::FrameworkSearchPath>
3630+
std::vector<swift::SearchPathOptions::SearchPath>
36283631
invocation_framework_paths(
36293632
invocation.getSearchPathOptions().getFrameworkSearchPaths());
36303633
// Add all deserialized paths to the map.
@@ -4049,7 +4052,7 @@ SwiftASTContext::GetModule(const FileSpec &module_spec) {
40494052
std::string module_directory(module_spec.GetDirectory().GetCString());
40504053
bool add_search_path = true;
40514054
for (auto path : ast->SearchPathOpts.getImportSearchPaths()) {
4052-
if (path == module_directory) {
4055+
if (path.Path == module_directory) {
40534056
add_search_path = false;
40544057
break;
40554058
}
@@ -5462,7 +5465,7 @@ void SwiftASTContextForExpressions::ModulesDidLoad(ModuleList &module_list) {
54625465
unsigned num_images = module_list.GetSize();
54635466
for (size_t mi = 0; mi != num_images; ++mi) {
54645467
std::vector<swift::PluginSearchOption> plugin_search_options;
5465-
std::vector<std::string> module_search_paths;
5468+
std::vector<std::pair<std::string, bool>> module_search_paths;
54665469
std::vector<std::pair<std::string, bool>> framework_search_paths;
54675470
std::vector<std::string> extra_clang_args;
54685471
lldb::ModuleSP module_sp = module_list.GetModuleAtIndex(mi);
@@ -5556,9 +5559,9 @@ void SwiftASTContext::LogConfiguration(bool is_repl) {
55565559
(unsigned long long)m_ast_context_ap->SearchPathOpts
55575560
.getImportSearchPaths()
55585561
.size());
5559-
for (const std::string &import_search_path :
5562+
for (const auto &import_search_path :
55605563
m_ast_context_ap->SearchPathOpts.getImportSearchPaths())
5561-
HEALTH_LOG_PRINTF(" %s", import_search_path.c_str());
5564+
HEALTH_LOG_PRINTF(" %s", import_search_path.Path.c_str());
55625565

55635566
swift::ClangImporterOptions &clang_importer_options =
55645567
GetClangImporterOptions();

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ class SwiftASTContext : public TypeSystemSwift {
253253
swift::SerializationOptions &GetSerializationOptions();
254254

255255
void InitializeSearchPathOptions(
256-
llvm::ArrayRef<std::string> module_search_paths,
256+
llvm::ArrayRef<std::pair<std::string, bool>> module_search_paths,
257257
llvm::ArrayRef<std::pair<std::string, bool>> framework_search_paths);
258258

259259
swift::ClangImporterOptions &GetClangImporterOptions();
@@ -277,13 +277,13 @@ class SwiftASTContext : public TypeSystemSwift {
277277
/// apply the working directory to any relative paths.
278278
void AddExtraClangArgs(
279279
const std::vector<std::string> &ExtraArgs,
280-
const std::vector<std::string> &module_search_paths,
280+
const std::vector<std::pair<std::string, bool>> module_search_paths,
281281
const std::vector<std::pair<std::string, bool>> framework_search_paths,
282282
llvm::StringRef overrideOpts = "");
283283

284284
void AddExtraClangCC1Args(
285285
const std::vector<std::string> &source,
286-
const std::vector<std::string> &module_search_paths,
286+
const std::vector<std::pair<std::string, bool>> module_search_paths,
287287
const std::vector<std::pair<std::string, bool>> framework_search_paths,
288288
std::vector<std::string> &dest);
289289
static void AddExtraClangArgs(const std::vector<std::string>& source,

0 commit comments

Comments
 (0)