@@ -1118,9 +1118,14 @@ static void printASTValidationError(
1118
1118
}
1119
1119
1120
1120
void SwiftASTContext::DiagnoseWarnings (Process &process, Module &module ) const {
1121
- if (HasDiagnostics ())
1122
- process.PrintWarningCantLoadSwiftModule (module ,
1123
- GetAllDiagnostics ().AsCString ());
1121
+ if (!HasDiagnostics ())
1122
+ return ;
1123
+ auto debugger_id = process.GetTarget ().GetDebugger ().GetID ();
1124
+ std::string msg;
1125
+ llvm::raw_string_ostream (msg) << " Cannot load Swift type information for "
1126
+ << module .GetFileSpec ().GetPath ();
1127
+ Debugger::ReportWarning (msg, debugger_id, &m_swift_import_warning);
1128
+ StreamAllDiagnostics (debugger_id);
1124
1129
}
1125
1130
1126
1131
// / Locate the swift-plugin-server for a plugin library,
@@ -2483,6 +2488,35 @@ Status SwiftASTContext::GetAllDiagnostics() const {
2483
2488
return error;
2484
2489
}
2485
2490
2491
+ void SwiftASTContext::StreamAllDiagnostics (
2492
+ llvm::Optional<lldb::user_id_t > debugger_id) const {
2493
+ Status error = m_fatal_errors;
2494
+ if (!error.Success ()) {
2495
+ Debugger::ReportWarning (error.AsCString (), debugger_id,
2496
+ &m_swift_diags_streamed);
2497
+ return ;
2498
+ }
2499
+
2500
+ // Retrieve the error message from the DiagnosticConsumer.
2501
+ DiagnosticManager diagnostic_manager;
2502
+ PrintDiagnostics (diagnostic_manager);
2503
+ for (auto &diag : diagnostic_manager.Diagnostics ())
2504
+ if (diag) {
2505
+ std::string msg = diag->GetMessage ().str ();
2506
+ switch (diag->GetSeverity ()) {
2507
+ case eDiagnosticSeverityError:
2508
+ Debugger::ReportError (msg, debugger_id, &m_swift_diags_streamed);
2509
+ break ;
2510
+ case eDiagnosticSeverityWarning:
2511
+ case eDiagnosticSeverityRemark:
2512
+ Debugger::ReportWarning (msg, debugger_id, &m_swift_warning_streamed);
2513
+ break ;
2514
+ }
2515
+ }
2516
+ static_cast <StoringDiagnosticConsumer *>(m_diagnostic_consumer_ap.get ())
2517
+ ->Clear ();
2518
+ }
2519
+
2486
2520
void SwiftASTContext::LogFatalErrors () const {
2487
2521
// Avoid spamming the health log with redundant copies of the fatal error.
2488
2522
if (m_logged_fatal_error) {
0 commit comments