@@ -1166,13 +1166,14 @@ static void printASTValidationError(
11661166 LLDB_LOG (log, " -- {0}" , ExtraOpt);
11671167}
11681168
1169- void SwiftASTContext::DiagnoseWarnings (Process &process, Module &module ) const {
1170- if (!HasDiagnostics ())
1169+ void SwiftASTContext::DiagnoseWarnings (Process &process,
1170+ const SymbolContext &sc) const {
1171+ if (!sc.module_sp || !HasDiagnostics ())
11711172 return ;
11721173 auto debugger_id = process.GetTarget ().GetDebugger ().GetID ();
11731174 std::string msg;
11741175 llvm::raw_string_ostream (msg) << " Cannot load Swift type information for "
1175- << module . GetFileSpec ().GetPath ();
1176+ << sc. module_sp -> GetFileSpec ().GetPath ();
11761177 Debugger::ReportWarning (msg, debugger_id, &m_swift_import_warning);
11771178 StreamAllDiagnostics (debugger_id);
11781179}
@@ -2111,7 +2112,8 @@ ProcessModule(Module &module, std::string m_description,
21112112 std::vector<swift::PluginSearchOption> &plugin_search_options,
21122113 std::vector<std::string> &module_search_paths,
21132114 std::vector<std::pair<std::string, bool >> &framework_search_paths,
2114- std::vector<std::string> &extra_clang_args) {
2115+ std::vector<std::string> &extra_clang_args,
2116+ std::string &error) {
21152117 {
21162118 llvm::raw_string_ostream ss (m_description);
21172119 ss << " ::ProcessModule(" << ' "' ;
@@ -2215,8 +2217,7 @@ ProcessModule(Module &module, std::string m_description,
22152217 return ;
22162218 bool found_swift_modules = false ;
22172219 bool got_serialized_options = false ;
2218- llvm::SmallString<0 > error;
2219- llvm::raw_svector_ostream errs (error);
2220+ llvm::raw_string_ostream errs (error);
22202221 swift::CompilerInvocation invocation;
22212222 auto ast_file_datas = module .GetASTData (eLanguageTypeSwift);
22222223 std::string module_name = module .GetSpecificationDescription ();
@@ -2365,7 +2366,7 @@ SwiftASTContext::CreateInstance(lldb::LanguageType language, Module &module,
23652366 bool got_serialized_options = false ;
23662367 llvm::SmallString<0 > error;
23672368 llvm::raw_svector_ostream errs (error);
2368- // Implicit search paths will be discovered by ValidateSecionModules ().
2369+ // Implicit search paths will be discovered by ValidateSectionModules ().
23692370 bool discover_implicit_search_paths = false ;
23702371 auto ast_file_datas = module .GetASTData (eLanguageTypeSwift);
23712372 std::string module_name = module .GetSpecificationDescription ();
@@ -2436,6 +2437,7 @@ SwiftASTContext::CreateInstance(lldb::LanguageType language, Module &module,
24362437 const bool use_all_compiler_flags = false ;
24372438 const bool is_target_module = true ;
24382439
2440+ std::string error;
24392441 StringRef module_filter;
24402442 std::vector<swift::PluginSearchOption> plugin_search_options;
24412443 std::vector<std::string> extra_clang_args = swift_ast_sp->GetClangArguments ();
@@ -2444,7 +2446,10 @@ SwiftASTContext::CreateInstance(lldb::LanguageType language, Module &module,
24442446 ProcessModule (module , m_description, discover_implicit_search_paths,
24452447 use_all_compiler_flags, is_target_module, module_filter, triple,
24462448 plugin_search_options, module_search_paths,
2447- framework_search_paths, extra_clang_args);
2449+ framework_search_paths, extra_clang_args, error);
2450+ if (!error.empty ())
2451+ swift_ast_sp->AddDiagnostic (eSeverityError, error);
2452+
24482453 // Apply the working directory to all relative paths.
24492454 StringRef overrideOpts = target ? target->GetSwiftClangOverrideOptions () : " " ;
24502455 swift_ast_sp->AddExtraClangArgs (extra_clang_args, overrideOpts);
@@ -2800,14 +2805,15 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
28002805
28012806 for (ModuleSP module_sp : target.GetImages ().Modules ())
28022807 if (module_sp) {
2808+ std::string error;
28032809 StringRef module_filter;
28042810 std::vector<std::string> extra_clang_args;
28052811 ProcessModule (*module_sp, m_description, discover_implicit_search_paths,
28062812 use_all_compiler_flags,
28072813 target.GetExecutableModulePointer () == module_sp.get (),
28082814 module_filter, triple, plugin_search_options,
28092815 module_search_paths, framework_search_paths,
2810- extra_clang_args);
2816+ extra_clang_args, error );
28112817 swift_ast_sp->AddExtraClangArgs (extra_clang_args,
28122818 target.GetSwiftClangOverrideOptions ());
28132819 }
@@ -3137,14 +3143,17 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
31373143 /* is_system*/ false });
31383144 ModuleSP module_sp = sc.module_sp ;
31393145 if (module_sp) {
3146+ std::string error;
31403147 StringRef module_filter = swift_module_name;
31413148 std::vector<std::string> extra_clang_args;
31423149 ProcessModule (*module_sp, m_description, discover_implicit_search_paths,
31433150 use_all_compiler_flags,
31443151 target.GetExecutableModulePointer () == module_sp.get (),
31453152 module_filter, triple, plugin_search_options,
3146- module_search_paths, framework_search_paths,
3147- extra_clang_args);
3153+ module_search_paths, framework_search_paths, extra_clang_args,
3154+ error);
3155+ if (!error.empty ())
3156+ swift_ast_sp->AddDiagnostic (eSeverityError, error);
31483157 swift_ast_sp->AddExtraClangArgs (extra_clang_args,
31493158 target.GetSwiftClangOverrideOptions ());
31503159 }
@@ -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