@@ -1219,17 +1219,29 @@ static bool DeserializeAllCompilerFlags(swift::CompilerInvocation &invocation,
1219
1219
INIT_SEARCH_PATH_SET (swift::SearchPathOptions::FrameworkSearchPath,
1220
1220
getFrameworkSearchPaths (), framework_search_paths,
1221
1221
.Path );
1222
- INIT_SEARCH_PATH_SET (std::string, PluginSearchPaths, plugin_search_paths, );
1223
- INIT_SEARCH_PATH_SET (swift::ExternalPluginSearchPathAndServerPath,
1224
- ExternalPluginSearchPaths, external_plugin_search_paths,
1225
- .SearchPath );
1226
- INIT_SEARCH_PATH_SET (std::string, getCompilerPluginLibraryPaths (),
1227
- compiler_plugin_library_paths, );
1228
- INIT_SEARCH_PATH_SET (swift::PluginExecutablePathAndModuleNames,
1229
- getCompilerPluginExecutablePaths (),
1230
- compiler_plugin_executable_paths, .ExecutablePath );
1231
-
1232
-
1222
+
1223
+ std::vector<swift::PluginSearchOption::Value> plugin_search_options;
1224
+ llvm::StringSet<> known_plugin_search_paths;
1225
+ llvm::StringSet<> known_external_plugin_search_paths;
1226
+ llvm::StringSet<> known_compiler_plugin_library_paths;
1227
+ llvm::StringSet<> known_compiler_plugin_executable_paths;
1228
+ for (auto &elem : search_path_options.PluginSearchOpts ) {
1229
+ plugin_search_options.push_back (elem);
1230
+
1231
+ #define INSERT_PATH_SET (SET, TYPE, KEY ) \
1232
+ if (auto *opt = elem.dyn_cast <swift::PluginSearchOption::TYPE>()) { \
1233
+ known_plugin_search_paths.insert (opt->KEY ); \
1234
+ continue ; \
1235
+ }
1236
+ INSERT_PATH_SET (known_plugin_search_paths, PluginPath, SearchPath);
1237
+ INSERT_PATH_SET (known_external_plugin_search_paths, ExternalPluginPath,
1238
+ SearchPath);
1239
+ INSERT_PATH_SET (known_compiler_plugin_library_paths, LoadPluginLibrary,
1240
+ LibraryPath);
1241
+ INSERT_PATH_SET (known_compiler_plugin_executable_paths,
1242
+ LoadPluginExecutable, ExecutablePath);
1243
+ }
1244
+
1233
1245
// An AST section consists of one or more AST modules, optionally
1234
1246
// with headers. Iterate over all AST modules.
1235
1247
for (auto ast_file_data_sp : ast_file_datas) {
@@ -1310,7 +1322,9 @@ static bool DeserializeAllCompilerFlags(swift::CompilerInvocation &invocation,
1310
1322
if (server.empty ())
1311
1323
continue ;
1312
1324
if (exists (path))
1313
- external_plugin_search_paths.push_back ({path.str (), server});
1325
+ plugin_search_options.emplace_back (
1326
+ swift::PluginSearchOption::ExternalPluginPath{path.str (),
1327
+ server});
1314
1328
}
1315
1329
}
1316
1330
}
@@ -1327,7 +1341,9 @@ static bool DeserializeAllCompilerFlags(swift::CompilerInvocation &invocation,
1327
1341
continue ;
1328
1342
if (known_external_plugin_search_paths.insert (plugin).second )
1329
1343
if (exists (plugin))
1330
- external_plugin_search_paths.push_back ({plugin.str (), server});
1344
+ plugin_search_options.emplace_back (
1345
+ swift::PluginSearchOption::ExternalPluginPath{plugin.str (),
1346
+ server});
1331
1347
}
1332
1348
1333
1349
for (auto dylib :
@@ -1353,7 +1369,9 @@ static bool DeserializeAllCompilerFlags(swift::CompilerInvocation &invocation,
1353
1369
// means this our translation attempts only work for
1354
1370
// macro libraries following this convention. cf.
1355
1371
// PluginLoader::lookupExternalLibraryPluginByModuleName().
1356
- external_plugin_search_paths.push_back ({dir.str ().str (), server});
1372
+ plugin_search_options.emplace_back (
1373
+ swift::PluginSearchOption::ExternalPluginPath{dir.str ().str (),
1374
+ server});
1357
1375
}
1358
1376
}
1359
1377
@@ -1370,8 +1388,9 @@ static bool DeserializeAllCompilerFlags(swift::CompilerInvocation &invocation,
1370
1388
modules_vec.push_back (m.str ());
1371
1389
if (known_compiler_plugin_executable_paths.insert (path).second )
1372
1390
if (exists (plugin))
1373
- compiler_plugin_executable_paths.push_back (
1374
- {plugin.str (), modules_vec});
1391
+ plugin_search_options.emplace_back (
1392
+ swift::PluginSearchOption::LoadPluginExecutable{plugin.str (),
1393
+ modules_vec});
1375
1394
}
1376
1395
return true ;
1377
1396
};
@@ -1390,12 +1409,7 @@ static bool DeserializeAllCompilerFlags(swift::CompilerInvocation &invocation,
1390
1409
search_path_options.setFrameworkSearchPaths (
1391
1410
std::move (framework_search_paths));
1392
1411
// (All PluginSearchPaths were rewritten to be external.)
1393
- search_path_options.ExternalPluginSearchPaths =
1394
- std::move (external_plugin_search_paths);
1395
- search_path_options.setCompilerPluginLibraryPaths (
1396
- std::move (compiler_plugin_library_paths));
1397
- search_path_options.setCompilerPluginExecutablePaths (
1398
- std::move (compiler_plugin_executable_paths));
1412
+ search_path_options.PluginSearchOpts = plugin_search_options;
1399
1413
return found_validation_errors;
1400
1414
}
1401
1415
@@ -2000,17 +2014,14 @@ static SwiftASTContext *GetModuleSwiftASTContext(Module &module) {
2000
2014
2001
2015
// / Scan a newly added lldb::Module for Swift modules and report any errors in
2002
2016
// / its module SwiftASTContext to Target.
2003
- static void
2004
- ProcessModule (ModuleSP module_sp, std::string m_description,
2005
- bool discover_implicit_search_paths, bool use_all_compiler_flags,
2006
- Target &target, llvm::Triple triple,
2007
- std::vector<swift::ExternalPluginSearchPathAndServerPath>
2008
- &external_plugin_search_paths,
2009
- std::vector<swift::PluginExecutablePathAndModuleNames>
2010
- &compiler_plugin_executable_paths,
2011
- std::vector<std::string> &module_search_paths,
2012
- std::vector<std::pair<std::string, bool >> &framework_search_paths,
2013
- std::vector<std::string> &extra_clang_args) {
2017
+ static void ProcessModule (
2018
+ ModuleSP module_sp, std::string m_description,
2019
+ bool discover_implicit_search_paths, bool use_all_compiler_flags,
2020
+ Target &target, llvm::Triple triple,
2021
+ std::vector<swift::PluginSearchOption::Value> &plugin_search_options,
2022
+ std::vector<std::string> &module_search_paths,
2023
+ std::vector<std::pair<std::string, bool >> &framework_search_paths,
2024
+ std::vector<std::string> &extra_clang_args) {
2014
2025
{
2015
2026
llvm::raw_string_ostream ss (m_description);
2016
2027
ss << " ::ProcessModule(" << ' "' ;
@@ -2128,13 +2139,9 @@ ProcessModule(ModuleSP module_sp, std::string m_description,
2128
2139
2129
2140
// Copy the interesting deserialized flags to the out parameters.
2130
2141
const auto &opts = invocation.getSearchPathOptions ();
2131
- external_plugin_search_paths.insert (external_plugin_search_paths.end (),
2132
- opts.ExternalPluginSearchPaths .begin (),
2133
- opts.ExternalPluginSearchPaths .end ());
2134
- compiler_plugin_executable_paths.insert (
2135
- compiler_plugin_executable_paths.end (),
2136
- opts.getCompilerPluginExecutablePaths ().begin (),
2137
- opts.getCompilerPluginExecutablePaths ().end ());
2142
+ plugin_search_options.insert (plugin_search_options.end (),
2143
+ opts.PluginSearchOpts .begin (),
2144
+ opts.PluginSearchOpts .end ());
2138
2145
module_search_paths.insert (module_search_paths.end (),
2139
2146
opts.getImportSearchPaths ().begin (),
2140
2147
opts.getImportSearchPaths ().end ());
@@ -2157,10 +2164,7 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
2157
2164
2158
2165
LLDB_SCOPED_TIMER ();
2159
2166
std::string m_description = " SwiftASTContextForExpressions" ;
2160
- std::vector<swift::ExternalPluginSearchPathAndServerPath>
2161
- external_plugin_search_paths;
2162
- std::vector<swift::PluginExecutablePathAndModuleNames>
2163
- compiler_plugin_executable_paths;
2167
+ std::vector<swift::PluginSearchOption::Value> plugin_search_options;
2164
2168
std::vector<std::string> module_search_paths;
2165
2169
std::vector<std::pair<std::string, bool >> framework_search_paths;
2166
2170
TargetSP target_sp = typeref_typesystem.GetTargetWP ().lock ();
@@ -2334,8 +2338,7 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
2334
2338
std::vector<std::string> extra_clang_args;
2335
2339
ProcessModule (target.GetImages ().GetModuleAtIndex (mi), m_description,
2336
2340
discover_implicit_search_paths, use_all_compiler_flags,
2337
- target, triple, external_plugin_search_paths,
2338
- compiler_plugin_executable_paths, module_search_paths,
2341
+ target, triple, plugin_search_options, module_search_paths,
2339
2342
framework_search_paths, extra_clang_args);
2340
2343
swift_ast_sp->AddExtraClangArgs (extra_clang_args);
2341
2344
}
@@ -2383,12 +2386,9 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
2383
2386
2384
2387
// Initialize the compiler plugin search paths.
2385
2388
auto &opts = swift_ast_sp->GetSearchPathOptions ();
2386
- opts.ExternalPluginSearchPaths .insert (opts.ExternalPluginSearchPaths .end (),
2387
- external_plugin_search_paths.begin (),
2388
- external_plugin_search_paths.end ());
2389
- assert (opts.getCompilerPluginExecutablePaths ().empty ());
2390
- opts.setCompilerPluginExecutablePaths (
2391
- std::move (compiler_plugin_executable_paths));
2389
+ opts.PluginSearchOpts .insert (opts.PluginSearchOpts .end (),
2390
+ plugin_search_options.begin (),
2391
+ plugin_search_options.end ());
2392
2392
2393
2393
for (size_t mi = 0 ; mi != num_images; ++mi) {
2394
2394
std::vector<std::string> module_names;
@@ -4629,18 +4629,14 @@ void SwiftASTContextForExpressions::ModulesDidLoad(ModuleList &module_list) {
4629
4629
bool use_all_compiler_flags = target_sp->GetUseAllCompilerFlags ();
4630
4630
unsigned num_images = module_list.GetSize ();
4631
4631
for (size_t mi = 0 ; mi != num_images; ++mi) {
4632
- std::vector<swift::ExternalPluginSearchPathAndServerPath>
4633
- external_plugin_search_paths;
4634
- std::vector<swift::PluginExecutablePathAndModuleNames>
4635
- compiler_plugin_executable_paths;
4632
+ std::vector<swift::PluginSearchOption::Value> plugin_search_options;
4636
4633
std::vector<std::string> module_search_paths;
4637
4634
std::vector<std::pair<std::string, bool >> framework_search_paths;
4638
4635
std::vector<std::string> extra_clang_args;
4639
4636
lldb::ModuleSP module_sp = module_list.GetModuleAtIndex (mi);
4640
4637
ProcessModule (module_sp, m_description, discover_implicit_search_paths,
4641
4638
use_all_compiler_flags, *target_sp, GetTriple (),
4642
- external_plugin_search_paths,
4643
- compiler_plugin_executable_paths, module_search_paths,
4639
+ plugin_search_options, module_search_paths,
4644
4640
framework_search_paths, extra_clang_args);
4645
4641
// If the use-all-compiler-flags setting is enabled, the
4646
4642
// expression context is supposed to merge all search paths
@@ -4736,33 +4732,39 @@ void SwiftASTContext::LogConfiguration() {
4736
4732
HEALTH_LOG_PRINTF (" %s" , extra_arg.c_str ());
4737
4733
}
4738
4734
4739
- #define PRINT_PLUGIN_PATHS (ACCESSOR, NAME, TEMPLATE, ...) \
4740
- { \
4741
- auto paths = m_ast_context_ap->SearchPathOpts .ACCESSOR ; \
4742
- HEALTH_LOG_PRINTF (" %s: (%llu items)" , NAME, \
4743
- (unsigned long long )paths.size ()); \
4744
- for (auto &path : paths) { \
4745
- HEALTH_LOG_PRINTF (" " TEMPLATE, ##__VA_ARGS__); \
4746
- } \
4735
+ HEALTH_LOG_PRINTF (" Plugin search options : (%llu items)" ,
4736
+ (unsigned long long )m_ast_context_ap->SearchPathOpts
4737
+ .PluginSearchOpts .size ());
4738
+ for (auto &elem : m_ast_context_ap->SearchPathOpts .PluginSearchOpts ) {
4739
+ if (auto *opt =
4740
+ elem.dyn_cast <swift::PluginSearchOption::LoadPluginLibrary>()) {
4741
+ HEALTH_LOG_PRINTF (" -load-plugin-library %s" ,
4742
+ opt->LibraryPath .c_str ());
4743
+ continue ;
4744
+ }
4745
+ if (auto *opt =
4746
+ elem.dyn_cast <swift::PluginSearchOption::LoadPluginExecutable>()) {
4747
+ HEALTH_LOG_PRINTF (" -load-plugin-executable %s#%s" ,
4748
+ opt->ExecutablePath .c_str (),
4749
+ [](auto path_names) -> std::string {
4750
+ std::string s;
4751
+ llvm::raw_string_ostream os (s);
4752
+ llvm::interleaveComma (path_names, os);
4753
+ return os.str ();
4754
+ }(opt->ModuleNames )
4755
+ .c_str ());
4756
+ continue ;
4757
+ }
4758
+ if (auto *opt = elem.dyn_cast <swift::PluginSearchOption::PluginPath>()) {
4759
+ HEALTH_LOG_PRINTF (" -plugin-path %s" , opt->SearchPath .c_str ());
4760
+ continue ;
4761
+ }
4762
+ if (auto *opt =
4763
+ elem.dyn_cast <swift::PluginSearchOption::ExternalPluginPath>()) {
4764
+ HEALTH_LOG_PRINTF (" -external-plugin-path %s#%s" ,
4765
+ opt->SearchPath .c_str (), opt->ServerPath .c_str ());
4766
+ }
4747
4767
}
4748
- PRINT_PLUGIN_PATHS (getCompilerPluginLibraryPaths (),
4749
- " Compiler Plugin Library Paths " ,
4750
- " %s" , path.c_str ());
4751
- PRINT_PLUGIN_PATHS (getCompilerPluginExecutablePaths (),
4752
- " Compiler Plugin Executable Paths " , " %s: [%s]" ,
4753
- path.ExecutablePath .c_str (),
4754
- [](auto path_names) -> std::string {
4755
- std::string s;
4756
- llvm::raw_string_ostream os (s);
4757
- llvm::interleaveComma (path_names, os);
4758
- return os.str ();
4759
- }(path.ModuleNames )
4760
- .c_str ());
4761
- PRINT_PLUGIN_PATHS (PluginSearchPaths, " Plugin search paths " ,
4762
- " %s" , path.c_str ());
4763
- PRINT_PLUGIN_PATHS (ExternalPluginSearchPaths,
4764
- " External plugin search paths " , " %s (server: %s)" ,
4765
- path.SearchPath .c_str (), path.ServerPath .c_str ());
4766
4768
}
4767
4769
4768
4770
bool SwiftASTContext::HasTarget () {
0 commit comments