Skip to content

Commit 0062dc6

Browse files
Merge pull request #10685 from adrian-prantl/150066908
[lldb] Remove the Swift-specific diagnosis frame callback
2 parents 74f18b3 + ed02858 commit 0062dc6

File tree

9 files changed

+17
-88
lines changed

9 files changed

+17
-88
lines changed

lldb/include/lldb/Symbol/TypeSystem.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -578,13 +578,6 @@ class TypeSystem : public PluginInterface,
578578
// meaningless type itself, instead preferring to use the dynamic type
579579
virtual bool IsMeaninglessWithoutDynamicResolution(void *type);
580580

581-
/// A TypeSystem may belong to more than one debugger, so it doesn't
582-
/// have a way to communicate errors. This method can be called by a
583-
/// process to tell the TypeSystem to send any diagnostics to the
584-
/// process so they can be surfaced to the user.
585-
virtual void DiagnoseWarnings(Process &process,
586-
const SymbolContext &sc) const;
587-
588581
virtual std::optional<llvm::json::Value> ReportStatistics();
589582

590583
bool GetHasForcefullyCompletedTypes() const {

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp

Lines changed: 15 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
32683227
void 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

53775336
void 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

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -482,15 +482,12 @@ class SwiftASTContext : public TypeSystemSwift {
482482
void RaiseFatalError(std::string msg) const { m_fatal_errors = Status(msg); }
483483
static bool HasFatalErrors(swift::ASTContext *ast_context);
484484
bool HasFatalErrors() const {
485-
return m_fatal_errors.Fail() || HasFatalErrors(m_ast_context_ap.get());
485+
return m_logged_fatal_error || m_fatal_errors.Fail() ||
486+
HasFatalErrors(m_ast_context_ap.get());
486487
}
487488

488489
/// Return only fatal errors.
489490
Status GetFatalErrors() const;
490-
/// Notify the Process about any Swift or ClangImporter errors.
491-
void DiagnoseWarnings(Process &process,
492-
const SymbolContext &sc) const override;
493-
494491
void PrintDiagnostics(DiagnosticManager &diagnostic_manager,
495492
uint32_t bufferID = UINT32_MAX, uint32_t first_line = 0,
496493
uint32_t last_line = UINT32_MAX) const;
@@ -884,8 +881,6 @@ class SwiftASTContext : public TypeSystemSwift {
884881
/// Called by the VALID_OR_RETURN macro to log all errors.
885882
void LogFatalErrors() const;
886883
Status GetAllDiagnostics() const;
887-
/// Stream all diagnostics to the Debugger and clear them.
888-
void StreamAllDiagnostics(std::optional<lldb::user_id_t> debugger_id) const;
889884

890885
llvm::TargetOptions *getTargetOptions();
891886

@@ -945,7 +940,6 @@ class SwiftASTContext : public TypeSystemSwift {
945940
std::unique_ptr<swift::irgen::IRGenModule> m_ir_gen_module_ap;
946941
llvm::once_flag m_ir_gen_module_once;
947942
mutable std::once_flag m_swift_import_warning;
948-
mutable std::once_flag m_swift_diags_streamed;
949943
mutable std::once_flag m_swift_warning_streamed;
950944
std::unique_ptr<swift::DiagnosticConsumer> m_diagnostic_consumer_ap;
951945
std::unique_ptr<swift::DependencyTracker> m_dependency_tracker;

lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2378,13 +2378,6 @@ Status TypeSystemSwiftTypeRef::IsCompatible() {
23782378
return {};
23792379
}
23802380

2381-
void TypeSystemSwiftTypeRef::DiagnoseWarnings(Process &process,
2382-
const SymbolContext &sc) const {
2383-
// This gets called only from Thread::FrameSelectedCallback(StackFrame).
2384-
if (auto swift_ast_context = GetSwiftASTContextOrNull(sc))
2385-
swift_ast_context->DiagnoseWarnings(process, sc);
2386-
}
2387-
23882381
plugin::dwarf::DWARFASTParser *TypeSystemSwiftTypeRef::GetDWARFParser() {
23892382
if (!m_dwarf_ast_parser_up)
23902383
m_dwarf_ast_parser_up.reset(new DWARFASTParserSwift(*this));

lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ class TypeSystemSwiftTypeRef : public TypeSystemSwift {
116116
bool SupportsLanguage(lldb::LanguageType language) override;
117117
Status IsCompatible() override;
118118

119-
void DiagnoseWarnings(Process &process,
120-
const SymbolContext &sc) const override;
121119
plugin::dwarf::DWARFASTParser *GetDWARFParser() override;
122120
// CompilerDecl functions
123121
ConstString DeclGetName(void *opaque_decl) override {

lldb/source/Symbol/TypeSystem.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,6 @@ bool TypeSystem::IsMeaninglessWithoutDynamicResolution(void *type) {
183183
return false;
184184
}
185185

186-
void TypeSystem::DiagnoseWarnings(Process &process,
187-
const SymbolContext &sc) const {}
188-
189186
Status TypeSystem::IsCompatible() {
190187
// Assume a language is compatible. Override this virtual function
191188
// in your TypeSystem plug-in if version checking is desired.

lldb/source/Target/Thread.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@
5353
#include "lldb/ValueObject/ValueObjectConstResult.h"
5454
#include "lldb/lldb-enumerations.h"
5555

56-
#ifdef LLDB_ENABLE_SWIFT
57-
#include "Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.h"
58-
#endif
59-
6056
#include <memory>
6157
#include <optional>
6258

@@ -348,19 +344,6 @@ void Thread::FrameSelectedCallback(StackFrame *frame) {
348344
GetProcess()->PrintWarningToolchainMismatch(sc);
349345
#endif
350346
}
351-
#ifdef LLDB_ENABLE_SWIFT
352-
{
353-
SymbolContext msc =
354-
frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextModule);
355-
Status error;
356-
ExecutionContext exe_ctx;
357-
frame->CalculateExecutionContext(exe_ctx);
358-
if (auto target = frame->CalculateTarget())
359-
if (auto swift_ast_ctx =
360-
TypeSystemSwiftTypeRefForExpressions::GetForTarget(*target))
361-
swift_ast_ctx->DiagnoseWarnings(*GetProcess(), msc);
362-
}
363-
#endif
364347
}
365348

366349
lldb::StopInfoSP Thread::GetStopInfo() {

lldb/test/Shell/Swift/DeserializationFailure.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,4 @@ run
1818
expression 1
1919

2020
# The {{ }} avoids accidentally matching the input script!
21-
# CHECK: {{ }}a.out
2221
# CHECK: {{ }}The serialized module is corrupted.

lldb/test/Shell/Swift/MissingVFSOverlay.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,4 @@ run
1515
expression 1
1616

1717
# The {{ }} avoids accidentally matching the input script!
18-
# CHECK: warning:{{ }}{{.*}}Swift{{.*}}a.out
1918
# CHECK: warning:{{ }}{{.*}}Ignoring missing VFS{{.*}}overlay.yaml

0 commit comments

Comments
 (0)