Skip to content

Commit b182c96

Browse files
committed
Print diagnostic group names by default
Print diagnostic groups as part of the LLVM printer in the same manner as the Swift one does, always. Make `-print-diagnostic-groups` an inert option, since we always print diagnostic group names with the `[#GroupName]` syntax. As part of this, we no longer render the diagnostic group name as part of the diagnostic *text*, instead leaving it up to the diagnostic renderer to handle the category appropriately. Update all of the tests that were depending on `-print-diagnostic-groups` putting it into the text to instead use the `{{documentation-file=<file name>}}` diagnostic verification syntax.
1 parent e88f899 commit b182c96

34 files changed

+320
-325
lines changed

β€Žlib/AST/DiagnosticEngine.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,6 +1618,7 @@ DiagnosticEngine::getFormatStringForDiagnostic(const Diagnostic &diagnostic,
16181618
};
16191619
switch (printDiagnosticNamesMode) {
16201620
case PrintDiagnosticNamesMode::None:
1621+
case PrintDiagnosticNamesMode::Group:
16211622
break;
16221623
case PrintDiagnosticNamesMode::Identifier: {
16231624
// If this diagnostic is a wrapper for another diagnostic, use the ID of
@@ -1632,13 +1633,6 @@ DiagnosticEngine::getFormatStringForDiagnostic(const Diagnostic &diagnostic,
16321633
message = formatMessageWithName(message, diagnosticIDStringFor(diagID));
16331634
break;
16341635
}
1635-
case PrintDiagnosticNamesMode::Group:
1636-
auto groupID = diagnostic.getGroupID();
1637-
if (groupID != DiagGroupID::no_group) {
1638-
message =
1639-
formatMessageWithName(message, getDiagGroupInfoByID(groupID).name);
1640-
}
1641-
break;
16421636
}
16431637

16441638
return message;

β€Žlib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2559,8 +2559,6 @@ static bool ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
25592559
}
25602560
if (Args.hasArg(OPT_debug_diagnostic_names)) {
25612561
Opts.PrintDiagnosticNames = PrintDiagnosticNamesMode::Identifier;
2562-
} else if (Args.hasArg(OPT_print_diagnostic_groups)) {
2563-
Opts.PrintDiagnosticNames = PrintDiagnosticNamesMode::Group;
25642562
}
25652563
if (Arg *A = Args.getLastArg(OPT_diagnostic_documentation_path)) {
25662564
Opts.DiagnosticDocumentationPath = A->getValue();

β€Žlib/Frontend/PrintingDiagnosticConsumer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ void PrintingDiagnosticConsumer::handleDiagnostic(SourceManager &SM,
5959
#endif
6060

6161
// Fall through when we don't have the new diagnostics renderer available.
62+
// This also happens if the location of the diagnostic is invalid, because
63+
// the new rendered cannot cope with that.
6264
LLVM_FALLTHROUGH;
6365
}
6466

@@ -134,6 +136,9 @@ void PrintingDiagnosticConsumer::printDiagnostic(SourceManager &SM,
134136
llvm::raw_svector_ostream Out(Text);
135137
DiagnosticEngine::formatDiagnosticText(Out, Info.FormatString,
136138
Info.FormatArgs);
139+
140+
if (!Info.Category.empty())
141+
Out << " [#" << Info.Category << "]";
137142
}
138143

139144
auto Msg = SM.GetMessage(Info.Loc, SMKind, Text, Ranges, FixIts,

β€Žtest/Concurrency/concurrentfunction_capturediagnostics.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// RUN: %target-swift-frontend -print-diagnostic-groups -target %target-swift-5.1-abi-triple -enable-experimental-flow-sensitive-concurrent-captures -verify -emit-sil %s -o - >/dev/null
2-
// RUN: %target-swift-frontend -print-diagnostic-groups -target %target-swift-5.1-abi-triple -enable-experimental-flow-sensitive-concurrent-captures -verify -emit-sil %s -o - >/dev/null -strict-concurrency=targeted
3-
// RUN: %target-swift-frontend -print-diagnostic-groups -target %target-swift-5.1-abi-triple -enable-experimental-flow-sensitive-concurrent-captures -verify -emit-sil %s -o - >/dev/null -strict-concurrency=complete
4-
// RUN: %target-swift-frontend -print-diagnostic-groups -target %target-swift-5.1-abi-triple -enable-experimental-flow-sensitive-concurrent-captures -verify -emit-sil %s -o - >/dev/null -strict-concurrency=complete -enable-upcoming-feature RegionBasedIsolation
1+
// RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple -enable-experimental-flow-sensitive-concurrent-captures -verify -emit-sil %s -o - >/dev/null
2+
// RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple -enable-experimental-flow-sensitive-concurrent-captures -verify -emit-sil %s -o - >/dev/null -strict-concurrency=targeted
3+
// RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple -enable-experimental-flow-sensitive-concurrent-captures -verify -emit-sil %s -o - >/dev/null -strict-concurrency=complete
4+
// RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple -enable-experimental-flow-sensitive-concurrent-captures -verify -emit-sil %s -o - >/dev/null -strict-concurrency=complete -enable-upcoming-feature RegionBasedIsolation
55

66
// REQUIRES: concurrency
77
// REQUIRES: swift_feature_RegionBasedIsolation
@@ -90,7 +90,7 @@ func testCaseTrivialValue4() {
9090
// expected-note @-8 {{capturing use}}
9191
}
9292

93-
class Klass: UnsafeSendable { // expected-warning{{'UnsafeSendable' is deprecated: Use @unchecked Sendable instead [DeprecatedDeclaration]}}
93+
class Klass: UnsafeSendable { // expected-warning{{'UnsafeSendable' is deprecated: Use @unchecked Sendable instead}}{{documentation-file=deprecated-declaration}}
9494
var next: Klass? = nil
9595
}
9696
func inoutUserKlass(_ k: inout Klass) {}

β€Žtest/Concurrency/custom_executor_enqueue_availability.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// RUN: %target-swift-frontend -print-diagnostic-groups -enable-experimental-move-only %s -emit-sil -o /dev/null -verify
2-
// RUN: %target-swift-frontend -print-diagnostic-groups -enable-experimental-move-only %s -emit-sil -o /dev/null -verify -strict-concurrency=targeted
3-
// RUN: %target-swift-frontend -print-diagnostic-groups -enable-experimental-move-only %s -emit-sil -o /dev/null -verify -strict-concurrency=complete
4-
// RUN: %target-swift-frontend -print-diagnostic-groups -enable-experimental-move-only %s -emit-sil -o /dev/null -verify -strict-concurrency=complete -enable-upcoming-feature RegionBasedIsolation
1+
// RUN: %target-swift-frontend -enable-experimental-move-only %s -emit-sil -o /dev/null -verify
2+
// RUN: %target-swift-frontend -enable-experimental-move-only %s -emit-sil -o /dev/null -verify -strict-concurrency=targeted
3+
// RUN: %target-swift-frontend -enable-experimental-move-only %s -emit-sil -o /dev/null -verify -strict-concurrency=complete
4+
// RUN: %target-swift-frontend -enable-experimental-move-only %s -emit-sil -o /dev/null -verify -strict-concurrency=complete -enable-upcoming-feature RegionBasedIsolation
55

66
// REQUIRES: concurrency
77
// REQUIRES: OS=macosx
@@ -55,7 +55,7 @@ final class TripleExecutor: SerialExecutor {
5555

5656
// expected-warning@+2{{'Job' is deprecated: renamed to 'ExecutorJob'}}
5757
// expected-note@+1{{use 'ExecutorJob' instead}}
58-
func enqueue(_ job: __owned Job) {} // expected-warning{{'Executor.enqueue(Job)' is deprecated as a protocol requirement; conform type 'TripleExecutor' to 'Executor' by implementing 'func enqueue(ExecutorJob)' instead [DeprecatedDeclaration]}}
58+
func enqueue(_ job: __owned Job) {} // expected-warning{{'Executor.enqueue(Job)' is deprecated as a protocol requirement; conform type 'TripleExecutor' to 'Executor' by implementing 'func enqueue(ExecutorJob)' instead}}{{documentation-file=deprecated-declaration}}
5959

6060
func enqueue(_ job: consuming ExecutorJob) {}
6161

β€Žtest/Concurrency/custom_executor_enqueue_impls.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// RUN: %target-swift-frontend -print-diagnostic-groups -disable-availability-checking -emit-sil -o /dev/null -verify %s
2-
// RUN: %target-swift-frontend -print-diagnostic-groups -disable-availability-checking -emit-sil -o /dev/null -verify -strict-concurrency=targeted %s
3-
// RUN: %target-swift-frontend -print-diagnostic-groups -disable-availability-checking -emit-sil -o /dev/null -verify -strict-concurrency=complete %s
4-
// RUN: %target-swift-frontend -print-diagnostic-groups -disable-availability-checking -emit-sil -o /dev/null -verify -strict-concurrency=complete -enable-upcoming-feature RegionBasedIsolation %s
1+
// RUN: %target-swift-frontend -disable-availability-checking -emit-sil -o /dev/null -verify %s
2+
// RUN: %target-swift-frontend -disable-availability-checking -emit-sil -o /dev/null -verify -strict-concurrency=targeted %s
3+
// RUN: %target-swift-frontend -disable-availability-checking -emit-sil -o /dev/null -verify -strict-concurrency=complete %s
4+
// RUN: %target-swift-frontend -disable-availability-checking -emit-sil -o /dev/null -verify -strict-concurrency=complete -enable-upcoming-feature RegionBasedIsolation %s
55

66
// REQUIRES: concurrency
77
// REQUIRES: swift_feature_RegionBasedIsolation
@@ -41,7 +41,7 @@ final class TripleExecutor: SerialExecutor {
4141

4242
// expected-warning@+2{{'Job' is deprecated: renamed to 'ExecutorJob'}}
4343
// expected-note@+1{{use 'ExecutorJob' instead}}
44-
func enqueue(_ job: __owned Job) {} // expected-warning{{'Executor.enqueue(Job)' is deprecated as a protocol requirement; conform type 'TripleExecutor' to 'Executor' by implementing 'func enqueue(ExecutorJob)' instead [DeprecatedDeclaration]}}
44+
func enqueue(_ job: __owned Job) {} // expected-warning{{'Executor.enqueue(Job)' is deprecated as a protocol requirement; conform type 'TripleExecutor' to 'Executor' by implementing 'func enqueue(ExecutorJob)' instead}}{{documentation-file=deprecated-declaration}}
4545

4646
func enqueue(_ job: consuming ExecutorJob) {}
4747

@@ -65,7 +65,7 @@ final class NoneExecutor: SerialExecutor { // expected-error{{type 'NoneExecutor
6565
final class StillDeprecated: SerialExecutor {
6666
// expected-warning@+2{{'Job' is deprecated: renamed to 'ExecutorJob'}}
6767
// expected-note@+1{{use 'ExecutorJob' instead}}
68-
func enqueue(_ job: __owned Job) {} // expected-warning{{'Executor.enqueue(Job)' is deprecated as a protocol requirement; conform type 'StillDeprecated' to 'Executor' by implementing 'func enqueue(ExecutorJob)' instead [DeprecatedDeclaration]}}
68+
func enqueue(_ job: __owned Job) {} // expected-warning{{'Executor.enqueue(Job)' is deprecated as a protocol requirement; conform type 'StillDeprecated' to 'Executor' by implementing 'func enqueue(ExecutorJob)' instead}}{{documentation-file=deprecated-declaration}}
6969

7070
func asUnownedSerialExecutor() -> UnownedSerialExecutor {
7171
UnownedSerialExecutor(ordinary: self)

β€Žtest/Sema/availability_literals.swift

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-typecheck-verify-swift -swift-version 5 -print-diagnostic-groups
1+
// RUN: %target-typecheck-verify-swift -swift-version 5
22

33
// REQUIRES: OS=macosx
44

@@ -10,8 +10,8 @@ extension SLD: ExpressibleByStringLiteral {
1010
init(stringLiteral value: StringLiteralType) {}
1111
}
1212

13-
let _ = SLD(stringLiteral: "") // expected-warning{{'init(stringLiteral:)' is deprecated [DeprecatedDeclaration]}}
14-
let _: SLD = "" // expected-warning{{'init(stringLiteral:)' is deprecated [DeprecatedDeclaration]}}
13+
let _ = SLD(stringLiteral: "") // expected-warning{{'init(stringLiteral:)' is deprecated}}{{documentation-file=deprecated-declaration}}
14+
let _: SLD = "" // expected-warning{{'init(stringLiteral:)' is deprecated}}{{documentation-file=deprecated-declaration}}
1515

1616

1717
struct SLU {}
@@ -30,8 +30,8 @@ extension ILD: ExpressibleByIntegerLiteral {
3030
init(integerLiteral value: IntegerLiteralType) {}
3131
}
3232

33-
let _ = ILD(integerLiteral: 1) // expected-warning{{'init(integerLiteral:)' is deprecated [DeprecatedDeclaration]}}
34-
let _: ILD = 1 // expected-warning{{'init(integerLiteral:)' is deprecated [DeprecatedDeclaration]}}
33+
let _ = ILD(integerLiteral: 1) // expected-warning{{'init(integerLiteral:)' is deprecated}}{{documentation-file=deprecated-declaration}}
34+
let _: ILD = 1 // expected-warning{{'init(integerLiteral:)' is deprecated}}{{documentation-file=deprecated-declaration}}
3535

3636
struct ILU {}
3737

@@ -51,8 +51,8 @@ extension NLD: ExpressibleByNilLiteral {
5151
init(nilLiteral: ()) {}
5252
}
5353

54-
let _: NLD = .init(nilLiteral: ()) // expected-warning{{'init(nilLiteral:)' is deprecated [DeprecatedDeclaration]}}
55-
let _: NLD = nil // expected-warning{{'init(nilLiteral:)' is deprecated [DeprecatedDeclaration]}}
54+
let _: NLD = .init(nilLiteral: ()) // expected-warning{{'init(nilLiteral:)' is deprecated}}{{documentation-file=deprecated-declaration}}
55+
let _: NLD = nil // expected-warning{{'init(nilLiteral:)' is deprecated}}{{documentation-file=deprecated-declaration}}
5656

5757
struct NLU {}
5858

@@ -70,8 +70,8 @@ struct BLD {}
7070
extension BLD: ExpressibleByBooleanLiteral {
7171
init(booleanLiteral value: BooleanLiteralType) {}
7272
}
73-
let _: BLD = .init(booleanLiteral: false) // expected-warning{{'init(booleanLiteral:)' is deprecated [DeprecatedDeclaration]}}
74-
let _: BLD = false // expected-warning{{'init(booleanLiteral:)' is deprecated [DeprecatedDeclaration]}}
73+
let _: BLD = .init(booleanLiteral: false) // expected-warning{{'init(booleanLiteral:)' is deprecated}}{{documentation-file=deprecated-declaration}}
74+
let _: BLD = false // expected-warning{{'init(booleanLiteral:)' is deprecated}}{{documentation-file=deprecated-declaration}}
7575

7676
struct BLU {}
7777
@available(macOS 100, *)
@@ -87,8 +87,8 @@ struct FLD {}
8787
extension FLD: ExpressibleByFloatLiteral {
8888
init(floatLiteral value: FloatLiteralType) {}
8989
}
90-
let _: FLD = .init(floatLiteral: 0.1) // expected-warning{{'init(floatLiteral:)' is deprecated [DeprecatedDeclaration]}}
91-
let _: FLD = 0.1 // expected-warning{{'init(floatLiteral:)' is deprecated [DeprecatedDeclaration]}}
90+
let _: FLD = .init(floatLiteral: 0.1) // expected-warning{{'init(floatLiteral:)' is deprecated}}{{documentation-file=deprecated-declaration}}
91+
let _: FLD = 0.1 // expected-warning{{'init(floatLiteral:)' is deprecated}}{{documentation-file=deprecated-declaration}}
9292

9393
struct FLU {}
9494
@available(macOS 100, *)
@@ -104,8 +104,8 @@ struct ALD {}
104104
extension ALD: ExpressibleByArrayLiteral {
105105
init(arrayLiteral elements: Int...) {}
106106
}
107-
let _: ALD = .init(arrayLiteral: 1) // expected-warning{{'init(arrayLiteral:)' is deprecated [DeprecatedDeclaration]}}
108-
let _: ALD = [1] // expected-warning{{'init(arrayLiteral:)' is deprecated [DeprecatedDeclaration]}}
107+
let _: ALD = .init(arrayLiteral: 1) // expected-warning{{'init(arrayLiteral:)' is deprecated}}{{documentation-file=deprecated-declaration}}
108+
let _: ALD = [1] // expected-warning{{'init(arrayLiteral:)' is deprecated}}{{documentation-file=deprecated-declaration}}
109109

110110
struct ALU {}
111111
@available(macOS 100, *)
@@ -121,8 +121,8 @@ struct DLD {}
121121
extension DLD: ExpressibleByDictionaryLiteral {
122122
init(dictionaryLiteral elements: (Int, Int)...) {}
123123
}
124-
let _: DLD = .init(dictionaryLiteral: (1,1)) // expected-warning{{'init(dictionaryLiteral:)' is deprecated [DeprecatedDeclaration]}}
125-
let _: DLD = [1: 1] // expected-warning{{'init(dictionaryLiteral:)' is deprecated [DeprecatedDeclaration]}}
124+
let _: DLD = .init(dictionaryLiteral: (1,1)) // expected-warning{{'init(dictionaryLiteral:)' is deprecated}}{{documentation-file=deprecated-declaration}}
125+
let _: DLD = [1: 1] // expected-warning{{'init(dictionaryLiteral:)' is deprecated}}{{documentation-file=deprecated-declaration}}
126126

127127
struct DLU {}
128128
@available(macOS 100, *)
@@ -139,8 +139,8 @@ extension USLD: ExpressibleByUnicodeScalarLiteral {
139139
typealias UnicodeScalarLiteralType = Character
140140
init(unicodeScalarLiteral value: UnicodeScalarLiteralType) {}
141141
}
142-
let _: USLD = .init(unicodeScalarLiteral: "a") // expected-warning{{'init(unicodeScalarLiteral:)' is deprecated [DeprecatedDeclaration]}}
143-
let _: USLD = "a" // expected-warning{{'init(unicodeScalarLiteral:)' is deprecated [DeprecatedDeclaration]}}
142+
let _: USLD = .init(unicodeScalarLiteral: "a") // expected-warning{{'init(unicodeScalarLiteral:)' is deprecated}}{{documentation-file=deprecated-declaration}}
143+
let _: USLD = "a" // expected-warning{{'init(unicodeScalarLiteral:)' is deprecated}}{{documentation-file=deprecated-declaration}}
144144

145145
struct USLU {}
146146
@available(macOS 100, *)
@@ -157,8 +157,8 @@ struct GCLD {}
157157
extension GCLD: ExpressibleByExtendedGraphemeClusterLiteral {
158158
init(extendedGraphemeClusterLiteral value: Character) {}
159159
}
160-
let _: GCLD = .init(extendedGraphemeClusterLiteral: "πŸ‡§πŸ‡·") // expected-warning{{'init(extendedGraphemeClusterLiteral:)' is deprecated [DeprecatedDeclaration]}}
161-
let _: GCLD = "πŸ‡§πŸ‡·" // expected-warning{{'init(extendedGraphemeClusterLiteral:)' is deprecated [DeprecatedDeclaration]}}
160+
let _: GCLD = .init(extendedGraphemeClusterLiteral: "πŸ‡§πŸ‡·") // expected-warning{{'init(extendedGraphemeClusterLiteral:)' is deprecated}}{{documentation-file=deprecated-declaration}}
161+
let _: GCLD = "πŸ‡§πŸ‡·" // expected-warning{{'init(extendedGraphemeClusterLiteral:)' is deprecated}}{{documentation-file=deprecated-declaration}}
162162

163163
struct GCLU {}
164164
@available(macOS 100, *)
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// RUN: %target-typecheck-verify-swift \
2-
// RUN: -disable-availability-checking \
3-
// RUN: -print-diagnostic-groups
2+
// RUN: -disable-availability-checking
43

5-
struct S : _BitwiseCopyable {} // expected-warning {{'_BitwiseCopyable' is deprecated: Use BitwiseCopyable [DeprecatedDeclaration]}}
4+
struct S : _BitwiseCopyable {} // expected-warning {{'_BitwiseCopyable' is deprecated: Use BitwiseCopyable}}{{documentation-file=deprecated-declaration}}
65

7-
func f<T : _BitwiseCopyable>(_ t: T) {} // expected-warning {{'_BitwiseCopyable' is deprecated: Use BitwiseCopyable [DeprecatedDeclaration]}}
6+
func f<T : _BitwiseCopyable>(_ t: T) {} // expected-warning {{'_BitwiseCopyable' is deprecated: Use BitwiseCopyable}}{{documentation-file=deprecated-declaration}}

0 commit comments

Comments
Β (0)