Skip to content

Commit d0d3541

Browse files
authored
Merge pull request #58 from owenv/diag-info-refactor (#67)
[Diagnostics] Update SwiftASTContext to use the new DiagnosticConsumer interface
1 parent 86514fe commit d0d3541

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

lldb/source/Symbol/SwiftASTContext.cpp

+10-14
Original file line numberDiff line numberDiff line change
@@ -2856,24 +2856,20 @@ class StoringDiagnosticConsumer : public swift::DiagnosticConsumer {
28562856
m_ast_context.GetDiagnosticEngine().takeConsumers();
28572857
}
28582858

2859-
virtual void
2860-
handleDiagnostic(swift::SourceManager &source_mgr,
2861-
swift::SourceLoc source_loc, swift::DiagnosticKind kind,
2862-
llvm::StringRef formatString,
2863-
llvm::ArrayRef<swift::DiagnosticArgument> formatArgs,
2864-
const swift::DiagnosticInfo &info,
2865-
const swift::SourceLoc bufferIndirectlyCausingDiagnostic) {
2859+
virtual void handleDiagnostic(swift::SourceManager &source_mgr,
2860+
const swift::DiagnosticInfo &info) {
28662861
llvm::StringRef bufferName = "<anonymous>";
28672862
unsigned bufferID = 0;
28682863
std::pair<unsigned, unsigned> line_col = {0, 0};
28692864

28702865
llvm::SmallString<256> text;
28712866
{
28722867
llvm::raw_svector_ostream out(text);
2873-
swift::DiagnosticEngine::formatDiagnosticText(out, formatString,
2874-
formatArgs);
2868+
swift::DiagnosticEngine::formatDiagnosticText(out, info.FormatString,
2869+
info.FormatArgs);
28752870
}
28762871

2872+
swift::SourceLoc source_loc = info.Loc;
28772873
if (source_loc.isValid()) {
28782874
bufferID = source_mgr.findBufferContainingLoc(source_loc);
28792875
bufferName = source_mgr.getDisplayNameForLoc(source_loc);
@@ -2887,7 +2883,7 @@ class StoringDiagnosticConsumer : public swift::DiagnosticConsumer {
28872883
// we want to use its fixits:
28882884
bool use_fixits = false;
28892885
llvm::SourceMgr::DiagKind source_mgr_kind;
2890-
switch (kind) {
2886+
switch (info.Kind) {
28912887
default:
28922888
case swift::DiagnosticKind::Error:
28932889
source_mgr_kind = llvm::SourceMgr::DK_Error;
@@ -2924,23 +2920,23 @@ class StoringDiagnosticConsumer : public swift::DiagnosticConsumer {
29242920

29252921
if (message_ref.empty())
29262922
m_diagnostics.push_back(RawDiagnostic(
2927-
text.str(), kind, bufferName, bufferID, line_col.first,
2923+
text.str(), info.Kind, bufferName, bufferID, line_col.first,
29282924
line_col.second,
29292925
use_fixits ? info.FixIts
29302926
: llvm::ArrayRef<swift::Diagnostic::FixIt>()));
29312927
else
29322928
m_diagnostics.push_back(RawDiagnostic(
2933-
message_ref, kind, bufferName, bufferID, line_col.first,
2929+
message_ref, info.Kind, bufferName, bufferID, line_col.first,
29342930
line_col.second,
29352931
use_fixits ? info.FixIts
29362932
: llvm::ArrayRef<swift::Diagnostic::FixIt>()));
29372933
} else {
29382934
m_diagnostics.push_back(RawDiagnostic(
2939-
text.str(), kind, bufferName, bufferID, line_col.first,
2935+
text.str(), info.Kind, bufferName, bufferID, line_col.first,
29402936
line_col.second, llvm::ArrayRef<swift::Diagnostic::FixIt>()));
29412937
}
29422938

2943-
if (kind == swift::DiagnosticKind::Error)
2939+
if (info.Kind == swift::DiagnosticKind::Error)
29442940
m_num_errors++;
29452941
}
29462942

0 commit comments

Comments
 (0)