@@ -178,9 +178,6 @@ struct ASTContext::Implementation {
178
178
179
179
// / The declaration of Swift.AutoreleasingUnsafeMutablePointer<T>.memory.
180
180
VarDecl *AutoreleasingUnsafeMutablePointerMemoryDecl = nullptr ;
181
-
182
- // / The declaration of Swift.Void.
183
- TypeAliasDecl *VoidDecl = nullptr ;
184
181
185
182
// / The declaration of ObjectiveC.ObjCBool.
186
183
StructDecl *ObjCBoolDecl = nullptr ;
@@ -210,12 +207,6 @@ FOR_KNOWN_FOUNDATION_TYPES(CACHE_FOUNDATION_DECL)
210
207
// / func reserveCapacityForAppend(newElementsCount: Int)
211
208
FuncDecl *ArrayReserveCapacityDecl = nullptr ;
212
209
213
- // / func _unimplementedInitializer(className: StaticString).
214
- FuncDecl *UnimplementedInitializerDecl = nullptr ;
215
-
216
- // / func _undefined<T>(msg: StaticString, file: StaticString, line: UInt) -> T
217
- FuncDecl *UndefinedDecl = nullptr ;
218
-
219
210
// / func _stdlib_isOSVersionAtLeast(Builtin.Word,Builtin.Word, Builtin.word)
220
211
// -> Builtin.Int1
221
212
FuncDecl *IsOSVersionAtLeastDecl = nullptr ;
@@ -641,25 +632,6 @@ void ASTContext::lookupInSwiftModule(
641
632
M->lookupValue ({ }, identifier, NLKind::UnqualifiedLookup, results);
642
633
}
643
634
644
- // / Find the generic implementation declaration for the named syntactic-sugar
645
- // / type.
646
- static NominalTypeDecl *findStdlibType (const ASTContext &ctx, StringRef name,
647
- unsigned genericParams) {
648
- // Find all of the declarations with this name in the Swift module.
649
- SmallVector<ValueDecl *, 1 > results;
650
- ctx.lookupInSwiftModule (name, results);
651
- for (auto result : results) {
652
- if (auto nominal = dyn_cast<NominalTypeDecl>(result)) {
653
- auto params = nominal->getGenericParams ();
654
- if (genericParams == (params == nullptr ? 0 : params->size ())) {
655
- // We found it.
656
- return nominal;
657
- }
658
- }
659
- }
660
- return nullptr ;
661
- }
662
-
663
635
FuncDecl *ASTContext::getPlusFunctionOnRangeReplaceableCollection () const {
664
636
if (getImpl ().PlusFunctionOnRangeReplaceableCollection ) {
665
637
return getImpl ().PlusFunctionOnRangeReplaceableCollection ;
@@ -716,10 +688,20 @@ FuncDecl *ASTContext::getPlusFunctionOnString() const {
716
688
717
689
#define KNOWN_STDLIB_TYPE_DECL (NAME, DECL_CLASS, NUM_GENERIC_PARAMS ) \
718
690
DECL_CLASS *ASTContext::get##NAME##Decl() const { \
719
- if (!getImpl ().NAME ##Decl) \
720
- getImpl ().NAME ##Decl = dyn_cast_or_null<DECL_CLASS>( \
721
- findStdlibType (*this , #NAME, NUM_GENERIC_PARAMS)); \
722
- return getImpl ().NAME ##Decl; \
691
+ if (getImpl ().NAME ##Decl) \
692
+ return getImpl ().NAME ##Decl; \
693
+ SmallVector<ValueDecl *, 1 > results; \
694
+ lookupInSwiftModule (#NAME, results); \
695
+ for (auto result : results) { \
696
+ if (auto type = dyn_cast<DECL_CLASS>(result)) { \
697
+ auto params = type->getGenericParams (); \
698
+ if (NUM_GENERIC_PARAMS == (params == nullptr ? 0 : params->size ())) { \
699
+ getImpl ().NAME ##Decl = type; \
700
+ return type; \
701
+ } \
702
+ } \
703
+ } \
704
+ return nullptr ; \
723
705
}
724
706
#include " swift/AST/KnownStdlibTypes.def"
725
707
@@ -820,24 +802,6 @@ CanType ASTContext::getNeverType() const {
820
802
return neverDecl->getDeclaredType ()->getCanonicalType ();
821
803
}
822
804
823
- TypeAliasDecl *ASTContext::getVoidDecl () const {
824
- if (getImpl ().VoidDecl ) {
825
- return getImpl ().VoidDecl ;
826
- }
827
-
828
- // Go find 'Void' in the Swift module.
829
- SmallVector<ValueDecl *, 1 > results;
830
- lookupInSwiftModule (" Void" , results);
831
- for (auto result : results) {
832
- if (auto typeAlias = dyn_cast<TypeAliasDecl>(result)) {
833
- getImpl ().VoidDecl = typeAlias;
834
- return typeAlias;
835
- }
836
- }
837
-
838
- return getImpl ().VoidDecl ;
839
- }
840
-
841
805
StructDecl *ASTContext::getObjCBoolDecl () const {
842
806
if (!getImpl ().ObjCBoolDecl ) {
843
807
SmallVector<ValueDecl *, 1 > results;
@@ -1186,39 +1150,6 @@ FuncDecl *ASTContext::getArrayReserveCapacityDecl() const {
1186
1150
return nullptr ;
1187
1151
}
1188
1152
1189
- FuncDecl *
1190
- ASTContext::getUnimplementedInitializerDecl () const {
1191
- if (getImpl ().UnimplementedInitializerDecl )
1192
- return getImpl ().UnimplementedInitializerDecl ;
1193
-
1194
- // Look for the function.
1195
- auto decl = findLibraryIntrinsic (*this , " _unimplementedInitializer" );
1196
- if (!decl)
1197
- return nullptr ;
1198
-
1199
- if (!getIntrinsicCandidateType (decl, /* allowTypeMembers=*/ false ))
1200
- return nullptr ;
1201
-
1202
- // FIXME: Check inputs and outputs.
1203
-
1204
- getImpl ().UnimplementedInitializerDecl = decl;
1205
- return decl;
1206
- }
1207
-
1208
- FuncDecl *
1209
- ASTContext::getUndefinedDecl () const {
1210
- if (getImpl ().UndefinedDecl )
1211
- return getImpl ().UndefinedDecl ;
1212
-
1213
- // Look for the function.
1214
- auto decl = findLibraryIntrinsic (*this , " _undefined" );
1215
- if (!decl)
1216
- return nullptr ;
1217
-
1218
- getImpl ().UndefinedDecl = decl;
1219
- return decl;
1220
- }
1221
-
1222
1153
FuncDecl *ASTContext::getIsOSVersionAtLeastDecl () const {
1223
1154
if (getImpl ().IsOSVersionAtLeastDecl )
1224
1155
return getImpl ().IsOSVersionAtLeastDecl ;
0 commit comments