@@ -1312,9 +1312,10 @@ static bool DeserializeAllCompilerFlags(swift::CompilerInvocation &invocation,
1312
1312
known_##NAME.insert (path KEY); \
1313
1313
}
1314
1314
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,
1318
1319
getFrameworkSearchPaths (), framework_search_paths,
1319
1320
.Path );
1320
1321
@@ -1398,10 +1399,12 @@ static bool DeserializeAllCompilerFlags(swift::CompilerInvocation &invocation,
1398
1399
for (auto &searchPath : searchPaths) {
1399
1400
std::string path = remap (searchPath.Path );
1400
1401
if (!searchPath.IsFramework ) {
1402
+ swift::SearchPathOptions::SearchPath
1403
+ import_search_path (path, searchPath.IsSystem );
1401
1404
if (known_import_search_paths.insert (path).second )
1402
- import_search_paths.push_back (path );
1405
+ import_search_paths.push_back (import_search_path );
1403
1406
} else {
1404
- swift::SearchPathOptions::FrameworkSearchPath
1407
+ swift::SearchPathOptions::SearchPath
1405
1408
framework_search_path (path, searchPath.IsSystem );
1406
1409
if (known_framework_search_paths.insert (path).second )
1407
1410
framework_search_paths.push_back (framework_search_path);
@@ -1801,7 +1804,7 @@ static void applyOverrideOptions(std::vector<std::string> &args,
1801
1804
1802
1805
void SwiftASTContext::AddExtraClangArgs (
1803
1806
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,
1805
1808
const std::vector<std::pair<std::string, bool >> framework_search_paths,
1806
1809
StringRef overrideOpts) {
1807
1810
swift::ClangImporterOptions &importer_options = GetClangImporterOptions ();
@@ -1850,7 +1853,7 @@ void SwiftASTContext::AddExtraClangArgs(
1850
1853
1851
1854
void SwiftASTContext::AddExtraClangCC1Args (
1852
1855
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,
1854
1857
const std::vector<std::pair<std::string, bool >> framework_search_paths,
1855
1858
std::vector<std::string> &dest) {
1856
1859
clang::CompilerInvocation invocation;
@@ -1871,7 +1874,7 @@ void SwiftASTContext::AddExtraClangCC1Args(
1871
1874
// additional clang modules when doing type reconstruction.
1872
1875
for (auto &path : module_search_paths) {
1873
1876
clangArgs.push_back (" -I" );
1874
- clangArgs.push_back (path.c_str ());
1877
+ clangArgs.push_back (path.first . c_str ());
1875
1878
}
1876
1879
for (auto &path : default_paths) {
1877
1880
llvm::SmallString<128 > search_path (GetPlatformSDKPath ());
@@ -2204,7 +2207,7 @@ ProcessModule(Module &module, std::string m_description,
2204
2207
bool is_main_executable, StringRef module_filter,
2205
2208
llvm::Triple triple,
2206
2209
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,
2208
2211
std::vector<std::pair<std::string, bool >> &framework_search_paths,
2209
2212
std::vector<std::string> &extra_clang_args,
2210
2213
std::string &error) {
@@ -2301,7 +2304,7 @@ ProcessModule(Module &module, std::string m_description,
2301
2304
bool exists = false ;
2302
2305
llvm::sys::fs::is_directory (path, exists);
2303
2306
if (exists)
2304
- module_search_paths.push_back (std::string (path));
2307
+ module_search_paths.push_back ({ std::string (path), /* system */ false } );
2305
2308
}
2306
2309
2307
2310
// Create a one-off CompilerInvocation as a place to load the
@@ -2334,9 +2337,8 @@ ProcessModule(Module &module, std::string m_description,
2334
2337
plugin_search_options.insert (plugin_search_options.end (),
2335
2338
opts.PluginSearchOpts .begin (),
2336
2339
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 });
2340
2342
for (auto path : opts.getFrameworkSearchPaths ())
2341
2343
framework_search_paths.push_back ({path.Path , path.IsSystem });
2342
2344
auto &clang_opts = invocation.getClangImporterOptions ().ExtraArgs ;
@@ -2373,7 +2375,7 @@ SwiftASTContext::CreateInstance(lldb::LanguageType language, Module &module,
2373
2375
ss << ' "' << ' )' ;
2374
2376
}
2375
2377
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;
2377
2379
std::vector<std::pair<std::string, bool >> framework_search_paths;
2378
2380
2379
2381
LOG_PRINTF (GetLog (LLDBLog::Types), " (Module)" );
@@ -3025,7 +3027,7 @@ SwiftASTContext::CreateInstance(const SymbolContext &sc,
3025
3027
ConfigureModuleCachePath (*swift_ast_sp);
3026
3028
3027
3029
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;
3029
3031
std::vector<std::pair<std::string, bool >> framework_search_paths;
3030
3032
std::vector<std::string> extra_clang_args;
3031
3033
@@ -3037,10 +3039,11 @@ SwiftASTContext::CreateInstance(const SymbolContext &sc,
3037
3039
use_all_compiler_flags =
3038
3040
!got_serialized_options || target_sp->GetUseAllCompilerFlags ();
3039
3041
3042
+ const bool is_system = false ;
3043
+
3040
3044
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} );
3042
3046
3043
- const bool is_system = false ;
3044
3047
for (const FileSpec &path : target_sp->GetSwiftFrameworkSearchPaths ())
3045
3048
framework_search_paths.push_back ({path.GetPath (), is_system});
3046
3049
}
@@ -3528,7 +3531,7 @@ swift::SearchPathOptions &SwiftASTContext::GetSearchPathOptions() {
3528
3531
}
3529
3532
3530
3533
void SwiftASTContext::InitializeSearchPathOptions (
3531
- llvm::ArrayRef<std::string> extra_module_search_paths,
3534
+ llvm::ArrayRef<std::pair<std:: string, bool > > extra_module_search_paths,
3532
3535
llvm::ArrayRef<std::pair<std::string, bool >> extra_framework_search_paths) {
3533
3536
LLDB_SCOPED_TIMER ();
3534
3537
swift::CompilerInvocation &invocation = GetCompilerInvocation ();
@@ -3607,24 +3610,24 @@ void SwiftASTContext::InitializeSearchPathOptions(
3607
3610
}
3608
3611
3609
3612
llvm::StringMap<bool > processed;
3610
- std::vector<std::string > invocation_import_paths (
3613
+ std::vector<swift::SearchPathOptions::SearchPath > invocation_import_paths (
3611
3614
invocation.getSearchPathOptions ().getImportSearchPaths ());
3612
3615
// Add all deserialized paths to the map.
3613
3616
for (const auto &path : invocation_import_paths)
3614
- processed.insert ({path, false });
3617
+ processed.insert ({path. Path , path. IsSystem });
3615
3618
3616
3619
// Add/unique all extra paths.
3617
3620
for (const auto &path : extra_module_search_paths) {
3618
- auto it_notseen = processed.insert ({ path, false } );
3621
+ auto it_notseen = processed.insert (path);
3619
3622
if (it_notseen.second )
3620
- invocation_import_paths.push_back (path);
3623
+ invocation_import_paths.push_back ({ path. first , path. second } );
3621
3624
}
3622
3625
invocation.getSearchPathOptions ().setImportSearchPaths (
3623
3626
invocation_import_paths);
3624
3627
3625
3628
// This preserves the IsSystem bit, but deduplicates entries ignoring it.
3626
3629
processed.clear ();
3627
- std::vector<swift::SearchPathOptions::FrameworkSearchPath >
3630
+ std::vector<swift::SearchPathOptions::SearchPath >
3628
3631
invocation_framework_paths (
3629
3632
invocation.getSearchPathOptions ().getFrameworkSearchPaths ());
3630
3633
// Add all deserialized paths to the map.
@@ -4049,7 +4052,7 @@ SwiftASTContext::GetModule(const FileSpec &module_spec) {
4049
4052
std::string module_directory (module_spec.GetDirectory ().GetCString ());
4050
4053
bool add_search_path = true ;
4051
4054
for (auto path : ast->SearchPathOpts .getImportSearchPaths ()) {
4052
- if (path == module_directory) {
4055
+ if (path. Path == module_directory) {
4053
4056
add_search_path = false ;
4054
4057
break ;
4055
4058
}
@@ -5462,7 +5465,7 @@ void SwiftASTContextForExpressions::ModulesDidLoad(ModuleList &module_list) {
5462
5465
unsigned num_images = module_list.GetSize ();
5463
5466
for (size_t mi = 0 ; mi != num_images; ++mi) {
5464
5467
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;
5466
5469
std::vector<std::pair<std::string, bool >> framework_search_paths;
5467
5470
std::vector<std::string> extra_clang_args;
5468
5471
lldb::ModuleSP module_sp = module_list.GetModuleAtIndex (mi);
@@ -5556,9 +5559,9 @@ void SwiftASTContext::LogConfiguration(bool is_repl) {
5556
5559
(unsigned long long )m_ast_context_ap->SearchPathOpts
5557
5560
.getImportSearchPaths ()
5558
5561
.size ());
5559
- for (const std::string &import_search_path :
5562
+ for (const auto &import_search_path :
5560
5563
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 ());
5562
5565
5563
5566
swift::ClangImporterOptions &clang_importer_options =
5564
5567
GetClangImporterOptions ();
0 commit comments