@@ -1165,13 +1165,14 @@ static void printASTValidationError(
11651165 LLDB_LOG (log, " -- {0}" , ExtraOpt);
11661166}
11671167
1168- void SwiftASTContext::DiagnoseWarnings (Process &process, Module &module ) const {
1169- if (!HasDiagnostics ())
1168+ void SwiftASTContext::DiagnoseWarnings (Process &process,
1169+ const SymbolContext &sc) const {
1170+ if (!sc.module_sp || !HasDiagnostics ())
11701171 return ;
11711172 auto debugger_id = process.GetTarget ().GetDebugger ().GetID ();
11721173 std::string msg;
11731174 llvm::raw_string_ostream (msg) << " Cannot load Swift type information for "
1174- << module . GetFileSpec ().GetPath ();
1175+ << sc. module_sp -> GetFileSpec ().GetPath ();
11751176 Debugger::ReportWarning (msg, debugger_id, &m_swift_import_warning);
11761177 StreamAllDiagnostics (debugger_id);
11771178}
@@ -2110,7 +2111,8 @@ ProcessModule(Module &module, std::string m_description,
21102111 std::vector<swift::PluginSearchOption> &plugin_search_options,
21112112 std::vector<std::string> &module_search_paths,
21122113 std::vector<std::pair<std::string, bool >> &framework_search_paths,
2113- std::vector<std::string> &extra_clang_args) {
2114+ std::vector<std::string> &extra_clang_args,
2115+ std::string &error) {
21142116 {
21152117 llvm::raw_string_ostream ss (m_description);
21162118 ss << " ::ProcessModule(" << ' "' ;
@@ -2214,8 +2216,7 @@ ProcessModule(Module &module, std::string m_description,
22142216 return ;
22152217 bool found_swift_modules = false ;
22162218 bool got_serialized_options = false ;
2217- llvm::SmallString<0 > error;
2218- llvm::raw_svector_ostream errs (error);
2219+ llvm::raw_string_ostream errs (error);
22192220 swift::CompilerInvocation invocation;
22202221 auto ast_file_datas = module .GetASTData (eLanguageTypeSwift);
22212222 std::string module_name = module .GetSpecificationDescription ();
@@ -2364,7 +2365,7 @@ SwiftASTContext::CreateInstance(lldb::LanguageType language, Module &module,
23642365 bool got_serialized_options = false ;
23652366 llvm::SmallString<0 > error;
23662367 llvm::raw_svector_ostream errs (error);
2367- // Implicit search paths will be discovered by ValidateSecionModules ().
2368+ // Implicit search paths will be discovered by ValidateSectionModules ().
23682369 bool discover_implicit_search_paths = false ;
23692370 auto ast_file_datas = module .GetASTData (eLanguageTypeSwift);
23702371 std::string module_name = module .GetSpecificationDescription ();
@@ -2435,6 +2436,7 @@ SwiftASTContext::CreateInstance(lldb::LanguageType language, Module &module,
24352436 const bool use_all_compiler_flags = false ;
24362437 const bool is_target_module = true ;
24372438
2439+ std::string error;
24382440 StringRef module_filter;
24392441 std::vector<swift::PluginSearchOption> plugin_search_options;
24402442 std::vector<std::string> extra_clang_args = swift_ast_sp->GetClangArguments ();
@@ -2443,7 +2445,10 @@ SwiftASTContext::CreateInstance(lldb::LanguageType language, Module &module,
24432445 ProcessModule (module , m_description, discover_implicit_search_paths,
24442446 use_all_compiler_flags, is_target_module, module_filter, triple,
24452447 plugin_search_options, module_search_paths,
2446- framework_search_paths, extra_clang_args);
2448+ framework_search_paths, extra_clang_args, error);
2449+ if (!error.empty ())
2450+ swift_ast_sp->AddDiagnostic (eSeverityError, error);
2451+
24472452 // Apply the working directory to all relative paths.
24482453 StringRef overrideOpts = target ? target->GetSwiftClangOverrideOptions () : " " ;
24492454 swift_ast_sp->AddExtraClangArgs (extra_clang_args, overrideOpts);
@@ -2799,14 +2804,15 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
27992804
28002805 for (ModuleSP module_sp : target.GetImages ().Modules ())
28012806 if (module_sp) {
2807+ std::string error;
28022808 StringRef module_filter;
28032809 std::vector<std::string> extra_clang_args;
28042810 ProcessModule (*module_sp, m_description, discover_implicit_search_paths,
28052811 use_all_compiler_flags,
28062812 target.GetExecutableModulePointer () == module_sp.get (),
28072813 module_filter, triple, plugin_search_options,
28082814 module_search_paths, framework_search_paths,
2809- extra_clang_args);
2815+ extra_clang_args, error );
28102816 swift_ast_sp->AddExtraClangArgs (extra_clang_args,
28112817 target.GetSwiftClangOverrideOptions ());
28122818 }
@@ -3136,14 +3142,17 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
31363142 /* is_system*/ false });
31373143 ModuleSP module_sp = sc.module_sp ;
31383144 if (module_sp) {
3145+ std::string error;
31393146 StringRef module_filter = swift_module_name;
31403147 std::vector<std::string> extra_clang_args;
31413148 ProcessModule (*module_sp, m_description, discover_implicit_search_paths,
31423149 use_all_compiler_flags,
31433150 target.GetExecutableModulePointer () == module_sp.get (),
31443151 module_filter, triple, plugin_search_options,
3145- module_search_paths, framework_search_paths,
3146- extra_clang_args);
3152+ module_search_paths, framework_search_paths, extra_clang_args,
3153+ error);
3154+ if (!error.empty ())
3155+ swift_ast_sp->AddDiagnostic (eSeverityError, error);
31473156 swift_ast_sp->AddExtraClangArgs (extra_clang_args,
31483157 target.GetSwiftClangOverrideOptions ());
31493158 }
@@ -5602,13 +5611,16 @@ void SwiftASTContextForExpressions::ModulesDidLoad(ModuleList &module_list) {
56025611 lldb::ModuleSP module_sp = module_list.GetModuleAtIndex (mi);
56035612 if (!module_sp)
56045613 continue ;
5614+ std::string error;
56055615 StringRef module_filter;
56065616 ProcessModule (*module_sp, m_description, discover_implicit_search_paths,
56075617 use_all_compiler_flags,
56085618 target_sp->GetExecutableModulePointer () == module_sp.get (),
56095619 module_filter, GetTriple (), plugin_search_options,
5610- module_search_paths, framework_search_paths,
5611- extra_clang_args);
5620+ module_search_paths, framework_search_paths, extra_clang_args,
5621+ error);
5622+ if (!error.empty ())
5623+ AddDiagnostic (eSeverityError, error);
56125624 // If the use-all-compiler-flags setting is enabled, the
56135625 // expression context is supposed to merge all search paths
56145626 // from all dylibs.
0 commit comments