Skip to content

Commit 8a0dc2b

Browse files
committed
[DiagnosticBridge] Make sure that diagnostic queues up its child notes
`DiagnosticEngine` has an API that allows to attach notes to a "primary" diagnostic (an error or a warning). This works well with old formatting (`llvm`) but `swift` formatter doesn't display attached notes which makes some diagnostics very hard to work with i.e. `invalid_redecl`.
1 parent 80050bb commit 8a0dc2b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/AST/DiagnosticBridge.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ static void addQueueDiagnostic(void *queuedDiagnostics,
7777
documentationPath.size(),
7878
highlightRanges.data(),
7979
highlightRanges.size() / 2);
80+
81+
// TODO: A better way to do this would be to pass the notes as an
82+
// argument to `swift_ASTGen_addQueuedDiagnostic` but that requires
83+
// bridging of `Note` structure and new serialization.
84+
for (auto *childNote : info.ChildDiagnosticInfo) {
85+
addQueueDiagnostic(queuedDiagnostics, *childNote, SM);
86+
}
8087
}
8188

8289
void DiagnosticBridge::enqueueDiagnostic(SourceManager &SM,

0 commit comments

Comments
 (0)