@@ -1166,13 +1166,14 @@ static void printASTValidationError(
1166
1166
LLDB_LOG (log , " -- {0}" , ExtraOpt);
1167
1167
}
1168
1168
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 ())
1171
1172
return ;
1172
1173
auto debugger_id = process.GetTarget ().GetDebugger ().GetID ();
1173
1174
std::string msg;
1174
1175
llvm::raw_string_ostream (msg) << " Cannot load Swift type information for "
1175
- << module. GetFileSpec().GetPath();
1176
+ << sc. module_sp -> GetFileSpec ().GetPath ();
1176
1177
Debugger ::ReportWarning (msg, debugger_id, &m_swift_import_warning);
1177
1178
StreamAllDiagnostics (debugger_id);
1178
1179
}
@@ -2111,7 +2112,8 @@ ProcessModule(Module &module, std::string m_description,
2111
2112
std::vector<swift::PluginSearchOption> &plugin_search_options,
2112
2113
std::vector<std::string> &module_search_paths,
2113
2114
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) {
2115
2117
{
2116
2118
llvm::raw_string_ostream ss (m_description);
2117
2119
ss << " ::ProcessModule(" << ' "' ;
@@ -2215,8 +2217,7 @@ ProcessModule(Module &module, std::string m_description,
2215
2217
return ;
2216
2218
bool found_swift_modules = false ;
2217
2219
bool got_serialized_options = false ;
2218
- llvm::SmallString<0> error;
2219
- llvm::raw_svector_ostream errs(error);
2220
+ llvm::raw_string_ostream errs (error);
2220
2221
swift::CompilerInvocation invocation;
2221
2222
auto ast_file_datas = module.GetASTData (eLanguageTypeSwift);
2222
2223
std::string module_name = module.GetSpecificationDescription ();
@@ -2365,7 +2366,7 @@ SwiftASTContext::CreateInstance(lldb::LanguageType language, Module &module,
2365
2366
bool got_serialized_options = false ;
2366
2367
llvm::SmallString<0 > error;
2367
2368
llvm::raw_svector_ostream errs (error);
2368
- // Implicit search paths will be discovered by ValidateSecionModules ().
2369
+ // Implicit search paths will be discovered by ValidateSectionModules ().
2369
2370
bool discover_implicit_search_paths = false ;
2370
2371
auto ast_file_datas = module.GetASTData (eLanguageTypeSwift);
2371
2372
std::string module_name = module.GetSpecificationDescription ();
@@ -2436,6 +2437,7 @@ SwiftASTContext::CreateInstance(lldb::LanguageType language, Module &module,
2436
2437
const bool use_all_compiler_flags = false ;
2437
2438
const bool is_target_module = true ;
2438
2439
2440
+ std::string error;
2439
2441
StringRef module_filter;
2440
2442
std::vector<swift::PluginSearchOption> plugin_search_options;
2441
2443
std::vector<std::string> extra_clang_args = swift_ast_sp->GetClangArguments ();
@@ -2444,7 +2446,10 @@ SwiftASTContext::CreateInstance(lldb::LanguageType language, Module &module,
2444
2446
ProcessModule (module, m_description, discover_implicit_search_paths,
2445
2447
use_all_compiler_flags, is_target_module, module_filter, triple,
2446
2448
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
+
2448
2453
// Apply the working directory to all relative paths.
2449
2454
StringRef overrideOpts = target ? target->GetSwiftClangOverrideOptions () : " " ;
2450
2455
swift_ast_sp->AddExtraClangArgs (extra_clang_args, overrideOpts);
@@ -2800,14 +2805,15 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
2800
2805
2801
2806
for (ModuleSP module_sp : target.GetImages ().Modules ())
2802
2807
if (module_sp) {
2808
+ std::string error;
2803
2809
StringRef module_filter;
2804
2810
std::vector<std::string> extra_clang_args;
2805
2811
ProcessModule (*module_sp, m_description, discover_implicit_search_paths,
2806
2812
use_all_compiler_flags,
2807
2813
target.GetExecutableModulePointer () == module_sp.get (),
2808
2814
module_filter, triple, plugin_search_options,
2809
2815
module_search_paths, framework_search_paths,
2810
- extra_clang_args);
2816
+ extra_clang_args, error );
2811
2817
swift_ast_sp->AddExtraClangArgs (extra_clang_args,
2812
2818
target.GetSwiftClangOverrideOptions ());
2813
2819
}
@@ -3137,14 +3143,17 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
3137
3143
/* is_system*/ false });
3138
3144
ModuleSP module_sp = sc.module_sp ;
3139
3145
if (module_sp) {
3146
+ std::string error;
3140
3147
StringRef module_filter = swift_module_name;
3141
3148
std::vector<std::string> extra_clang_args;
3142
3149
ProcessModule (*module_sp, m_description, discover_implicit_search_paths,
3143
3150
use_all_compiler_flags,
3144
3151
target.GetExecutableModulePointer () == module_sp.get (),
3145
3152
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);
3148
3157
swift_ast_sp->AddExtraClangArgs (extra_clang_args,
3149
3158
target.GetSwiftClangOverrideOptions ());
3150
3159
}
@@ -5602,13 +5611,16 @@ void SwiftASTContextForExpressions::ModulesDidLoad(ModuleList &module_list) {
5602
5611
lldb::ModuleSP module_sp = module_list.GetModuleAtIndex (mi);
5603
5612
if (!module_sp)
5604
5613
continue ;
5614
+ std::string error;
5605
5615
StringRef module_filter;
5606
5616
ProcessModule (*module_sp, m_description, discover_implicit_search_paths,
5607
5617
use_all_compiler_flags,
5608
5618
target_sp->GetExecutableModulePointer () == module_sp.get (),
5609
5619
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);
5612
5624
// If the use-all-compiler-flags setting is enabled, the
5613
5625
// expression context is supposed to merge all search paths
5614
5626
// from all dylibs.
0 commit comments