From a63ced3e6451ec624e129918a4ef321b1c97a187 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Wed, 30 Oct 2019 14:49:14 -0700 Subject: [PATCH] Merge pull request #58 from owenv/diag-info-refactor [Diagnostics] Update SwiftASTContext to use the new DiagnosticConsumer interface --- lldb/source/Symbol/SwiftASTContext.cpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/lldb/source/Symbol/SwiftASTContext.cpp b/lldb/source/Symbol/SwiftASTContext.cpp index 19019e828137b0..bfb397156dc585 100644 --- a/lldb/source/Symbol/SwiftASTContext.cpp +++ b/lldb/source/Symbol/SwiftASTContext.cpp @@ -2856,13 +2856,8 @@ class StoringDiagnosticConsumer : public swift::DiagnosticConsumer { m_ast_context.GetDiagnosticEngine().takeConsumers(); } - virtual void - handleDiagnostic(swift::SourceManager &source_mgr, - swift::SourceLoc source_loc, swift::DiagnosticKind kind, - llvm::StringRef formatString, - llvm::ArrayRef formatArgs, - const swift::DiagnosticInfo &info, - const swift::SourceLoc bufferIndirectlyCausingDiagnostic) { + virtual void handleDiagnostic(swift::SourceManager &source_mgr, + const swift::DiagnosticInfo &info) { llvm::StringRef bufferName = ""; unsigned bufferID = 0; std::pair line_col = {0, 0}; @@ -2870,10 +2865,11 @@ class StoringDiagnosticConsumer : public swift::DiagnosticConsumer { llvm::SmallString<256> text; { llvm::raw_svector_ostream out(text); - swift::DiagnosticEngine::formatDiagnosticText(out, formatString, - formatArgs); + swift::DiagnosticEngine::formatDiagnosticText(out, info.FormatString, + info.FormatArgs); } + swift::SourceLoc source_loc = info.Loc; if (source_loc.isValid()) { bufferID = source_mgr.findBufferContainingLoc(source_loc); bufferName = source_mgr.getDisplayNameForLoc(source_loc); @@ -2887,7 +2883,7 @@ class StoringDiagnosticConsumer : public swift::DiagnosticConsumer { // we want to use its fixits: bool use_fixits = false; llvm::SourceMgr::DiagKind source_mgr_kind; - switch (kind) { + switch (info.Kind) { default: case swift::DiagnosticKind::Error: source_mgr_kind = llvm::SourceMgr::DK_Error; @@ -2924,23 +2920,23 @@ class StoringDiagnosticConsumer : public swift::DiagnosticConsumer { if (message_ref.empty()) m_diagnostics.push_back(RawDiagnostic( - text.str(), kind, bufferName, bufferID, line_col.first, + text.str(), info.Kind, bufferName, bufferID, line_col.first, line_col.second, use_fixits ? info.FixIts : llvm::ArrayRef())); else m_diagnostics.push_back(RawDiagnostic( - message_ref, kind, bufferName, bufferID, line_col.first, + message_ref, info.Kind, bufferName, bufferID, line_col.first, line_col.second, use_fixits ? info.FixIts : llvm::ArrayRef())); } else { m_diagnostics.push_back(RawDiagnostic( - text.str(), kind, bufferName, bufferID, line_col.first, + text.str(), info.Kind, bufferName, bufferID, line_col.first, line_col.second, llvm::ArrayRef())); } - if (kind == swift::DiagnosticKind::Error) + if (info.Kind == swift::DiagnosticKind::Error) m_num_errors++; }