@@ -1197,18 +1197,6 @@ static void printASTValidationError(
11971197 LLDB_LOG (log, " -- {0}" , ExtraOpt);
11981198}
11991199
1200- void SwiftASTContext::DiagnoseWarnings (Process &process,
1201- const SymbolContext &sc) const {
1202- if (!sc.module_sp || !HasDiagnostics ())
1203- return ;
1204- auto debugger_id = process.GetTarget ().GetDebugger ().GetID ();
1205- std::string msg;
1206- llvm::raw_string_ostream (msg) << " Cannot load Swift type information for "
1207- << sc.module_sp ->GetFileSpec ().GetPath ();
1208- Debugger::ReportWarning (msg, debugger_id, &m_swift_import_warning);
1209- StreamAllDiagnostics (debugger_id);
1210- }
1211-
12121200// / Locate the swift-plugin-server for a plugin library,
12131201// / by converting ${toolchain}/usr/(local)?/lib/swift/host/plugins
12141202// / into ${toolchain}/usr/bin/swift-plugin-server
@@ -3236,35 +3224,6 @@ Status SwiftASTContext::GetAllDiagnostics() const {
32363224 return error;
32373225}
32383226
3239- void SwiftASTContext::StreamAllDiagnostics (
3240- std::optional<lldb::user_id_t > debugger_id) const {
3241- Status error = m_fatal_errors.Clone ();
3242- if (!error.Success ()) {
3243- Debugger::ReportWarning (error.AsCString (), debugger_id,
3244- &m_swift_diags_streamed);
3245- return ;
3246- }
3247-
3248- // Retrieve the error message from the DiagnosticConsumer.
3249- DiagnosticManager diagnostic_manager;
3250- PrintDiagnostics (diagnostic_manager);
3251- for (auto &diag : diagnostic_manager.Diagnostics ())
3252- if (diag) {
3253- std::string msg = diag->GetMessage ().str ();
3254- switch (diag->GetSeverity ()) {
3255- case eSeverityError:
3256- Debugger::ReportError (msg, debugger_id, &m_swift_diags_streamed);
3257- break ;
3258- case eSeverityWarning:
3259- case eSeverityInfo:
3260- Debugger::ReportWarning (msg, debugger_id, &m_swift_warning_streamed);
3261- break ;
3262- }
3263- }
3264- static_cast <StoringDiagnosticConsumer *>(m_diagnostic_consumer_ap.get ())
3265- ->Clear ();
3266- }
3267-
32683227void SwiftASTContext::LogFatalErrors () const {
32693228 // Avoid spamming the health log with redundant copies of the fatal error.
32703229 if (m_logged_fatal_error) {
@@ -5376,8 +5335,22 @@ bool SwiftASTContext::HasClangImporterErrors() const {
53765335
53775336void SwiftASTContext::AddDiagnostic (lldb::Severity severity,
53785337 llvm::StringRef message) {
5379- assert (m_diagnostic_consumer_ap);
53805338 HEALTH_LOG_PRINTF (" %s" , message.str ().c_str ());
5339+
5340+ if (auto target_sp = GetTargetWP ().lock ()) {
5341+ auto debugger_id = target_sp->GetDebugger ().GetID ();
5342+ switch (severity) {
5343+ case eSeverityError:
5344+ Debugger::ReportError (message.str (), debugger_id);
5345+ break ;
5346+ case eSeverityWarning:
5347+ case eSeverityInfo:
5348+ Debugger::ReportWarning (message.str (), debugger_id);
5349+ break ;
5350+ }
5351+ }
5352+
5353+ assert (m_diagnostic_consumer_ap);
53815354 if (!m_diagnostic_consumer_ap.get ())
53825355 return ;
53835356
0 commit comments