@@ -35,17 +35,17 @@ bool swift::performanceHintDiagnosticsEnabled(ASTContext &ctx) {
35
35
!ctx.Diags .isIgnoredDiagnostic (
36
36
diag::perf_hint_function_returns_array.ID ) ||
37
37
!ctx.Diags .isIgnoredDiagnostic (
38
- diag::perf_hint_param_expects_existential_any .ID ) ||
38
+ diag::perf_hint_param_expects_existential .ID ) ||
39
39
!ctx.Diags .isIgnoredDiagnostic (
40
- diag::perf_hint_func_returns_existential_any .ID ) ||
40
+ diag::perf_hint_func_returns_existential .ID ) ||
41
41
!ctx.Diags .isIgnoredDiagnostic (
42
- diag::perf_hint_closure_returns_existential_any .ID ) ||
42
+ diag::perf_hint_closure_returns_existential .ID ) ||
43
43
!ctx.Diags .isIgnoredDiagnostic (
44
- diag::perf_hint_var_uses_existential_any .ID ) ||
44
+ diag::perf_hint_var_uses_existential .ID ) ||
45
45
!ctx.Diags .isIgnoredDiagnostic (
46
- diag::perf_hint_any_pattern_uses_existential_any .ID ) ||
46
+ diag::perf_hint_any_pattern_uses_existential .ID ) ||
47
47
!ctx.Diags .isIgnoredDiagnostic (
48
- diag::perf_hint_typealias_uses_existential_any .ID );
48
+ diag::perf_hint_typealias_uses_existential .ID );
49
49
}
50
50
51
51
namespace {
@@ -75,47 +75,45 @@ bool hasExistentialAnyInType(Type type) {
75
75
return type->getCanonicalType ().findIf (isExistentialType);
76
76
}
77
77
78
- void checkExistentialAnyInFunctionReturnType (FuncDecl *FD,
79
- DiagnosticEngine &Diags) {
78
+ void checkExistentialInFunctionReturnType (FuncDecl *FD,
79
+ DiagnosticEngine &Diags) {
80
80
Type T = FD->getResultInterfaceType ();
81
81
82
82
if (hasExistentialAnyInType (T))
83
- Diags.diagnose (FD, diag::perf_hint_func_returns_existential_any , FD);
83
+ Diags.diagnose (FD, diag::perf_hint_func_returns_existential , FD);
84
84
}
85
85
86
- void checkExistentialAnyInClosureReturnType (ClosureExpr *CE,
87
- DiagnosticEngine &Diags) {
86
+ void checkExistentialInClosureReturnType (ClosureExpr *CE,
87
+ DiagnosticEngine &Diags) {
88
88
Type T = CE->getResultType ();
89
89
90
90
if (hasExistentialAnyInType (T))
91
- Diags.diagnose (CE->getLoc (),
92
- diag::perf_hint_closure_returns_existential_any);
91
+ Diags.diagnose (CE->getLoc (), diag::perf_hint_closure_returns_existential);
93
92
}
94
93
95
- void checkExistentialAnyInVariableType (const VarDecl *VD,
96
- DiagnosticEngine &Diags) {
94
+ void checkExistentialInVariableType (const VarDecl *VD,
95
+ DiagnosticEngine &Diags) {
97
96
Type T = VD->getInterfaceType ();
98
97
99
98
if (hasExistentialAnyInType (T))
100
- Diags.diagnose (VD, diag::perf_hint_var_uses_existential_any , VD);
99
+ Diags.diagnose (VD, diag::perf_hint_var_uses_existential , VD);
101
100
}
102
101
103
- void checkExistentialAnyInPatternType (const AnyPattern *AP,
104
- DiagnosticEngine &Diags) {
102
+ void checkExistentialInPatternType (const AnyPattern *AP,
103
+ DiagnosticEngine &Diags) {
105
104
Type T = AP->getType ();
106
105
107
106
if (hasExistentialAnyInType (T))
108
- Diags.diagnose (AP->getLoc (),
109
- diag::perf_hint_any_pattern_uses_existential_any);
107
+ Diags.diagnose (AP->getLoc (), diag::perf_hint_any_pattern_uses_existential);
110
108
}
111
109
112
- void checkExistentialAnyInTypeAlias (const TypeAliasDecl *TAD,
113
- DiagnosticEngine &Diags) {
110
+ void checkExistentialInTypeAlias (const TypeAliasDecl *TAD,
111
+ DiagnosticEngine &Diags) {
114
112
Type T = TAD->getUnderlyingType ();
115
113
116
114
if (hasExistentialAnyInType (T))
117
- Diags.diagnose (TAD->getLoc (),
118
- diag::perf_hint_typealias_uses_existential_any, TAD);
115
+ Diags.diagnose (TAD->getLoc (), diag::perf_hint_typealias_uses_existential,
116
+ TAD);
119
117
}
120
118
121
119
// / Produce performance hint diagnostics for a SourceFile.
@@ -135,7 +133,7 @@ class PerformanceHintDiagnosticWalker final : public ASTWalker {
135
133
return Action::SkipNode (P);
136
134
137
135
if (const AnyPattern *AP = dyn_cast<AnyPattern>(P)) {
138
- checkExistentialAnyInPatternType (AP, Ctx.Diags );
136
+ checkExistentialInPatternType (AP, Ctx.Diags );
139
137
}
140
138
141
139
return Action::Continue (P);
@@ -158,7 +156,7 @@ class PerformanceHintDiagnosticWalker final : public ASTWalker {
158
156
" Traversing implicit expressions is disabled in the pre-walk visitor" );
159
157
160
158
if (auto Closure = dyn_cast<ClosureExpr>(E)) {
161
- checkExistentialAnyInClosureReturnType (Closure, Ctx.Diags );
159
+ checkExistentialInClosureReturnType (Closure, Ctx.Diags );
162
160
}
163
161
164
162
return Action::Continue (E);
@@ -171,9 +169,9 @@ class PerformanceHintDiagnosticWalker final : public ASTWalker {
171
169
if (const FuncDecl *FD = dyn_cast<FuncDecl>(D)) {
172
170
checkImplicitCopyReturnType (FD, Ctx.Diags );
173
171
} else if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
174
- checkExistentialAnyInVariableType (VD, Ctx.Diags );
172
+ checkExistentialInVariableType (VD, Ctx.Diags );
175
173
} else if (const TypeAliasDecl *TAD = dyn_cast<TypeAliasDecl>(D)) {
176
- checkExistentialAnyInTypeAlias (TAD, Ctx.Diags );
174
+ checkExistentialInTypeAlias (TAD, Ctx.Diags );
177
175
}
178
176
179
177
return Action::Continue ();
@@ -185,7 +183,7 @@ class PerformanceHintDiagnosticWalker final : public ASTWalker {
185
183
" Traversing implicit declarations is disabled in the pre-walk visitor" );
186
184
187
185
if (auto *FD = dyn_cast<FuncDecl>(D)) {
188
- checkExistentialAnyInFunctionReturnType (FD, Ctx.Diags );
186
+ checkExistentialInFunctionReturnType (FD, Ctx.Diags );
189
187
}
190
188
191
189
return Action::Continue ();
0 commit comments