@@ -1949,7 +1949,7 @@ static lldb::ModuleSP GetUnitTestModule(lldb_private::ModuleList &modules) {
1949
1949
// / Scan a newly added lldb::Module fdor Swift modules and report any errors in
1950
1950
// / its module SwiftASTContext to Target.
1951
1951
static void
1952
- ProcessModule (ModuleSP && module_sp, std::string m_description,
1952
+ ProcessModule (ModuleSP module_sp, std::string m_description,
1953
1953
bool use_all_compiler_flags, Target &target,
1954
1954
std::vector<std::string> &module_search_paths,
1955
1955
std::vector<std::pair<std::string, bool >> &framework_search_paths,
@@ -5069,6 +5069,37 @@ void SwiftASTContext::PrintDiagnostics(DiagnosticManager &diagnostic_manager,
5069
5069
5070
5070
void SwiftASTContext::ModulesDidLoad (ModuleList &module_list) {
5071
5071
ClearModuleDependentCaches ();
5072
+
5073
+ // Scan the new modules for Swift contents and try to import it if
5074
+ // safe, otherwise poison this context.
5075
+ TargetSP target_sp = GetTarget ().lock ();
5076
+ if (!target_sp)
5077
+ return ;
5078
+
5079
+ bool use_all_compiler_flags = target_sp->GetUseAllCompilerFlags ();
5080
+ unsigned num_images = module_list.GetSize ();
5081
+ for (size_t mi = 0 ; mi != num_images; ++mi) {
5082
+ std::vector<std::string> module_search_paths;
5083
+ std::vector<std::pair<std::string, bool >> framework_search_paths;
5084
+ std::vector<std::string> extra_clang_args;
5085
+ lldb::ModuleSP module_sp = module_list.GetModuleAtIndex (mi);
5086
+ ProcessModule (module_sp, m_description, use_all_compiler_flags, *target_sp,
5087
+ module_search_paths, framework_search_paths,
5088
+ extra_clang_args);
5089
+ // If the use-all-compiler-flags setting is enabled, the expression
5090
+ // context is supposed to merge all search paths form all dylibs.
5091
+ if (use_all_compiler_flags && !extra_clang_args.empty ()) {
5092
+ // We cannot reconfigure ClangImporter after its creation.
5093
+ // Instead poison the SwiftASTContext so it gets recreated.
5094
+ m_fatal_errors.SetErrorStringWithFormat (
5095
+ " New Swift image added: %s" ,
5096
+ module_sp->GetFileSpec ().GetPath ().c_str ());
5097
+ }
5098
+
5099
+ // Scan the dylib for .swiftast sections.
5100
+ std::vector<std::string> module_names;
5101
+ RegisterSectionModules (*module_sp, module_names);
5102
+ }
5072
5103
}
5073
5104
5074
5105
void SwiftASTContext::ClearModuleDependentCaches () {
0 commit comments