@@ -1101,8 +1101,9 @@ void PrintingDiagnosticConsumer::handleDiagnostic(SourceManager &SM,
11011101 return ;
11021102
11031103 switch (FormattingStyle) {
1104- case DiagnosticOptions::FormattingStyle::SwiftSyntax : {
1104+ case DiagnosticOptions::FormattingStyle::Swift : {
11051105#if SWIFT_SWIFT_PARSER
1106+ // Use the swift-syntax formatter.
11061107 auto bufferStack = getSourceBufferStack (SM, Info.Loc );
11071108 if (!bufferStack.empty ()) {
11081109 // If there are no enqueued diagnostics, or they are from a different
@@ -1121,34 +1122,38 @@ void PrintingDiagnosticConsumer::handleDiagnostic(SourceManager &SM,
11211122 enqueueDiagnostic (queuedDiagnostics, Info, SM);
11221123 break ;
11231124 }
1125+ #endif
1126+
1127+ // Use the C++ formatter.
1128+ // FIXME: Once the swift-syntax formatter is enabled everywhere, we will
1129+ // remove this.
1130+ if (Info.Loc .isValid ()) {
1131+ if (Info.Kind == DiagnosticKind::Note && currentSnippet) {
1132+ // If this is a note and we have an in-flight message, add it to that
1133+ // instead of emitting it separately.
1134+ annotateSnippetWithInfo (SM, Info, *currentSnippet);
1135+ } else {
1136+ // If we encounter a new error/warning/remark, flush any in-flight
1137+ // snippets.
1138+ flush (/* includeTrailingBreak*/ true );
1139+ currentSnippet = std::make_unique<AnnotatedSourceSnippet>(SM);
1140+ annotateSnippetWithInfo (SM, Info, *currentSnippet);
1141+ }
1142+ if (PrintEducationalNotes) {
1143+ for (auto path : Info.EducationalNotePaths ) {
1144+ if (auto buffer = SM.getFileSystem ()->getBufferForFile (path))
1145+ BufferedEducationalNotes.push_back (buffer->get ()->getBuffer ().str ());
1146+ }
1147+ }
1148+ break ;
1149+ }
11241150
11251151 // Fall through to print using the LLVM style when there is no source
11261152 // location.
11271153 flush (/* includeTrailingBreak*/ false );
1128- #endif
11291154 LLVM_FALLTHROUGH;
11301155 }
11311156
1132- case DiagnosticOptions::FormattingStyle::Swift:
1133- if (Info.Kind == DiagnosticKind::Note && currentSnippet) {
1134- // If this is a note and we have an in-flight message, add it to that
1135- // instead of emitting it separately.
1136- annotateSnippetWithInfo (SM, Info, *currentSnippet);
1137- } else {
1138- // If we encounter a new error/warning/remark, flush any in-flight
1139- // snippets.
1140- flush (/* includeTrailingBreak*/ true );
1141- currentSnippet = std::make_unique<AnnotatedSourceSnippet>(SM);
1142- annotateSnippetWithInfo (SM, Info, *currentSnippet);
1143- }
1144- if (PrintEducationalNotes) {
1145- for (auto path : Info.EducationalNotePaths ) {
1146- if (auto buffer = SM.getFileSystem ()->getBufferForFile (path))
1147- BufferedEducationalNotes.push_back (buffer->get ()->getBuffer ().str ());
1148- }
1149- }
1150- break ;
1151-
11521157 case DiagnosticOptions::FormattingStyle::LLVM:
11531158 printDiagnostic (SM, Info);
11541159
0 commit comments