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