Skip to content

Commit 52304ec

Browse files
committed
Replace all uses of "existential any" with "existential"
1 parent cbfb79d commit 52304ec

File tree

4 files changed

+96
-98
lines changed

4 files changed

+96
-98
lines changed

include/swift/AST/DiagnosticGroups.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ GROUP(WeakMutability, "weak-mutability")
8282
GROUP(PerformanceHints, "performance-hints")
8383
GROUP(ReturnTypeImplicitCopy, "return-type-implicit-copy")
8484
GROUP_LINK(PerformanceHints, ReturnTypeImplicitCopy)
85-
GROUP(ExistentialAnyType, "existential-any-type")
86-
GROUP_LINK(PerformanceHints, ExistentialAnyType)
85+
GROUP(ExistentialType, "existential-type")
86+
GROUP_LINK(PerformanceHints, ExistentialType)
8787

8888
#define UNDEFINE_DIAGNOSTIC_GROUPS_MACROS
8989
#include "swift/AST/DefineDiagnosticGroupsMacros.h"

include/swift/AST/DiagnosticsSema.def

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8946,27 +8946,27 @@ GROUPED_WARNING(perf_hint_closure_returns_array,ReturnTypeImplicitCopy,DefaultIg
89468946
"Performance: closure returns a%select{ dictionary|n array}0, leading to implicit copies. "
89478947
"Consider using an 'inout' parameter instead.", (bool))
89488948

8949-
GROUPED_WARNING(perf_hint_param_expects_existential_any,ExistentialAnyType,DefaultIgnore,
8950-
"Performance: %0 expects existential any, leading to heap allocation, reference counting, "
8949+
GROUPED_WARNING(perf_hint_param_expects_existential,ExistentialType,DefaultIgnore,
8950+
"Performance: %0 expects an existential, leading to heap allocation, reference counting, "
89518951
"and dynamic dispatch. Consider using generic constraints or concrete types instead.",
89528952
(const ParamDecl*))
8953-
GROUPED_WARNING(perf_hint_func_returns_existential_any,ExistentialAnyType,DefaultIgnore,
8954-
"Performance: %0 returns existential any, leading to heap allocation, reference counting, "
8953+
GROUPED_WARNING(perf_hint_func_returns_existential,ExistentialType,DefaultIgnore,
8954+
"Performance: %0 returns an existential, leading to heap allocation, reference counting, "
89558955
"and dynamic dispatch. Consider using generic constraints or concrete types instead.",
89568956
(const FuncDecl*))
8957-
GROUPED_WARNING(perf_hint_closure_returns_existential_any,ExistentialAnyType,DefaultIgnore,
8958-
"Performance: closure returns existential any, leading to heap allocation, reference counting, "
8957+
GROUPED_WARNING(perf_hint_closure_returns_existential,ExistentialType,DefaultIgnore,
8958+
"Performance: closure returns an existential, leading to heap allocation, reference counting, "
89598959
"and dynamic dispatch. Consider using generic constraints or concrete types instead.", ())
8960-
GROUPED_WARNING(perf_hint_var_uses_existential_any,ExistentialAnyType,DefaultIgnore,
8961-
"Performance: %0 uses existential any, leading to heap allocation, reference counting, "
8960+
GROUPED_WARNING(perf_hint_var_uses_existential,ExistentialType,DefaultIgnore,
8961+
"Performance: %0 uses an existential, leading to heap allocation, reference counting, "
89628962
"and dynamic dispatch. Consider using generic constraints or concrete types instead.",
89638963
(const VarDecl *))
8964-
GROUPED_WARNING(perf_hint_any_pattern_uses_existential_any,ExistentialAnyType,DefaultIgnore,
8965-
"Performance: Ignored value uses existential any, leading to heap allocation, reference counting, "
8964+
GROUPED_WARNING(perf_hint_any_pattern_uses_existential,ExistentialType,DefaultIgnore,
8965+
"Performance: Ignored value uses an existential, leading to heap allocation, reference counting, "
89668966
"and dynamic dispatch. Consider using generic constraints or concrete types instead.",
89678967
())
8968-
GROUPED_WARNING(perf_hint_typealias_uses_existential_any,ExistentialAnyType,DefaultIgnore,
8969-
"Performance: %0 aliases existential any type, leading to heap allocation, reference counting, "
8968+
GROUPED_WARNING(perf_hint_typealias_uses_existential,ExistentialType,DefaultIgnore,
8969+
"Performance: %0 aliases an existential type, leading to heap allocation, reference counting, "
89708970
"and dynamic dispatch. Consider using generic constraints or concrete types instead.",
89718971
(const TypeAliasDecl *))
89728972

lib/Sema/PerformanceHints.cpp

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ bool swift::performanceHintDiagnosticsEnabled(ASTContext &ctx) {
3535
!ctx.Diags.isIgnoredDiagnostic(
3636
diag::perf_hint_function_returns_array.ID) ||
3737
!ctx.Diags.isIgnoredDiagnostic(
38-
diag::perf_hint_param_expects_existential_any.ID) ||
38+
diag::perf_hint_param_expects_existential.ID) ||
3939
!ctx.Diags.isIgnoredDiagnostic(
40-
diag::perf_hint_func_returns_existential_any.ID) ||
40+
diag::perf_hint_func_returns_existential.ID) ||
4141
!ctx.Diags.isIgnoredDiagnostic(
42-
diag::perf_hint_closure_returns_existential_any.ID) ||
42+
diag::perf_hint_closure_returns_existential.ID) ||
4343
!ctx.Diags.isIgnoredDiagnostic(
44-
diag::perf_hint_var_uses_existential_any.ID) ||
44+
diag::perf_hint_var_uses_existential.ID) ||
4545
!ctx.Diags.isIgnoredDiagnostic(
46-
diag::perf_hint_any_pattern_uses_existential_any.ID) ||
46+
diag::perf_hint_any_pattern_uses_existential.ID) ||
4747
!ctx.Diags.isIgnoredDiagnostic(
48-
diag::perf_hint_typealias_uses_existential_any.ID);
48+
diag::perf_hint_typealias_uses_existential.ID);
4949
}
5050

5151
namespace {
@@ -75,47 +75,45 @@ bool hasExistentialAnyInType(Type type) {
7575
return type->getCanonicalType().findIf(isExistentialType);
7676
}
7777

78-
void checkExistentialAnyInFunctionReturnType(FuncDecl *FD,
79-
DiagnosticEngine &Diags) {
78+
void checkExistentialInFunctionReturnType(FuncDecl *FD,
79+
DiagnosticEngine &Diags) {
8080
Type T = FD->getResultInterfaceType();
8181

8282
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);
8484
}
8585

86-
void checkExistentialAnyInClosureReturnType(ClosureExpr *CE,
87-
DiagnosticEngine &Diags) {
86+
void checkExistentialInClosureReturnType(ClosureExpr *CE,
87+
DiagnosticEngine &Diags) {
8888
Type T = CE->getResultType();
8989

9090
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);
9392
}
9493

95-
void checkExistentialAnyInVariableType(const VarDecl *VD,
96-
DiagnosticEngine &Diags) {
94+
void checkExistentialInVariableType(const VarDecl *VD,
95+
DiagnosticEngine &Diags) {
9796
Type T = VD->getInterfaceType();
9897

9998
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);
101100
}
102101

103-
void checkExistentialAnyInPatternType(const AnyPattern *AP,
104-
DiagnosticEngine &Diags) {
102+
void checkExistentialInPatternType(const AnyPattern *AP,
103+
DiagnosticEngine &Diags) {
105104
Type T = AP->getType();
106105

107106
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);
110108
}
111109

112-
void checkExistentialAnyInTypeAlias(const TypeAliasDecl *TAD,
113-
DiagnosticEngine &Diags) {
110+
void checkExistentialInTypeAlias(const TypeAliasDecl *TAD,
111+
DiagnosticEngine &Diags) {
114112
Type T = TAD->getUnderlyingType();
115113

116114
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);
119117
}
120118

121119
/// Produce performance hint diagnostics for a SourceFile.
@@ -135,7 +133,7 @@ class PerformanceHintDiagnosticWalker final : public ASTWalker {
135133
return Action::SkipNode(P);
136134

137135
if (const AnyPattern *AP = dyn_cast<AnyPattern>(P)) {
138-
checkExistentialAnyInPatternType(AP, Ctx.Diags);
136+
checkExistentialInPatternType(AP, Ctx.Diags);
139137
}
140138

141139
return Action::Continue(P);
@@ -158,7 +156,7 @@ class PerformanceHintDiagnosticWalker final : public ASTWalker {
158156
"Traversing implicit expressions is disabled in the pre-walk visitor");
159157

160158
if (auto Closure = dyn_cast<ClosureExpr>(E)) {
161-
checkExistentialAnyInClosureReturnType(Closure, Ctx.Diags);
159+
checkExistentialInClosureReturnType(Closure, Ctx.Diags);
162160
}
163161

164162
return Action::Continue(E);
@@ -171,9 +169,9 @@ class PerformanceHintDiagnosticWalker final : public ASTWalker {
171169
if (const FuncDecl *FD = dyn_cast<FuncDecl>(D)) {
172170
checkImplicitCopyReturnType(FD, Ctx.Diags);
173171
} else if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
174-
checkExistentialAnyInVariableType(VD, Ctx.Diags);
172+
checkExistentialInVariableType(VD, Ctx.Diags);
175173
} else if (const TypeAliasDecl *TAD = dyn_cast<TypeAliasDecl>(D)) {
176-
checkExistentialAnyInTypeAlias(TAD, Ctx.Diags);
174+
checkExistentialInTypeAlias(TAD, Ctx.Diags);
177175
}
178176

179177
return Action::Continue();
@@ -185,7 +183,7 @@ class PerformanceHintDiagnosticWalker final : public ASTWalker {
185183
"Traversing implicit declarations is disabled in the pre-walk visitor");
186184

187185
if (auto *FD = dyn_cast<FuncDecl>(D)) {
188-
checkExistentialAnyInFunctionReturnType(FD, Ctx.Diags);
186+
checkExistentialInFunctionReturnType(FD, Ctx.Diags);
189187
}
190188

191189
return Action::Continue();

0 commit comments

Comments
 (0)