Skip to content

Commit 7c75836

Browse files
committed
context cleanup part 1
1 parent 473f3d2 commit 7c75836

File tree

6 files changed

+7
-71
lines changed

6 files changed

+7
-71
lines changed

include/swift/AST/ASTContext.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,6 @@ class ASTContext final {
469469
/// Retrieve the type Swift.Never.
470470
CanType getNeverType() const;
471471

472-
/// Retrieve the declaration of Swift.Void.
473-
TypeAliasDecl *getVoidDecl() const;
474-
475472
/// Retrieve the declaration of ObjectiveC.ObjCBool.
476473
StructDecl *getObjCBoolDecl() const;
477474

@@ -530,12 +527,6 @@ class ASTContext final {
530527
/// Array.reserveCapacityForAppend(newElementsCount: Int)
531528
FuncDecl *getArrayReserveCapacityDecl() const;
532529

533-
/// Retrieve the declaration of Swift._unimplementedInitializer.
534-
FuncDecl *getUnimplementedInitializerDecl() const;
535-
536-
/// Retrieve the declaration of Swift._undefined.
537-
FuncDecl *getUndefinedDecl() const;
538-
539530
// Retrieve the declaration of Swift._stdlib_isOSVersionAtLeast.
540531
FuncDecl *getIsOSVersionAtLeastDecl() const;
541532

include/swift/AST/KnownDecls.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,7 @@ FUNC_DECL(ModifyAtReferenceWritableKeyPath, "_modifyAtReferenceWritableKeyPath")
8383

8484
FUNC_DECL(Swap, "swap")
8585

86+
FUNC_DECL(UnimplementedInitializer, "_unimplementedInitializer")
87+
FUNC_DECL(Undefined, "_undefined")
88+
8689
#undef FUNC_DECL

include/swift/AST/KnownStdlibTypes.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#define KNOWN_STDLIB_TYPE_DECL(NAME, DECL_CLASS, NUM_GENERIC_PARAMS)
2626
#endif
2727

28+
KNOWN_STDLIB_TYPE_DECL(Void, TypeAliasDecl, 0)
29+
2830
KNOWN_STDLIB_TYPE_DECL(Bool, NominalTypeDecl, 0)
2931

3032
KNOWN_STDLIB_TYPE_DECL(Int, NominalTypeDecl, 0)

lib/AST/ASTContext.cpp

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,6 @@ struct ASTContext::Implementation {
178178

179179
/// The declaration of Swift.AutoreleasingUnsafeMutablePointer<T>.memory.
180180
VarDecl *AutoreleasingUnsafeMutablePointerMemoryDecl = nullptr;
181-
182-
/// The declaration of Swift.Void.
183-
TypeAliasDecl *VoidDecl = nullptr;
184181

185182
/// The declaration of ObjectiveC.ObjCBool.
186183
StructDecl *ObjCBoolDecl = nullptr;
@@ -210,12 +207,6 @@ FOR_KNOWN_FOUNDATION_TYPES(CACHE_FOUNDATION_DECL)
210207
/// func reserveCapacityForAppend(newElementsCount: Int)
211208
FuncDecl *ArrayReserveCapacityDecl = nullptr;
212209

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-
219210
/// func _stdlib_isOSVersionAtLeast(Builtin.Word,Builtin.Word, Builtin.word)
220211
// -> Builtin.Int1
221212
FuncDecl *IsOSVersionAtLeastDecl = nullptr;
@@ -820,24 +811,6 @@ CanType ASTContext::getNeverType() const {
820811
return neverDecl->getDeclaredType()->getCanonicalType();
821812
}
822813

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-
841814
StructDecl *ASTContext::getObjCBoolDecl() const {
842815
if (!getImpl().ObjCBoolDecl) {
843816
SmallVector<ValueDecl *, 1> results;
@@ -1186,39 +1159,6 @@ FuncDecl *ASTContext::getArrayReserveCapacityDecl() const {
11861159
return nullptr;
11871160
}
11881161

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-
12221162
FuncDecl *ASTContext::getIsOSVersionAtLeastDecl() const {
12231163
if (getImpl().IsOSVersionAtLeastDecl)
12241164
return getImpl().IsOSVersionAtLeastDecl;

lib/Sema/CSApply.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3795,7 +3795,7 @@ namespace {
37953795
auto &tc = cs.getTypeChecker();
37963796
auto &ctx = tc.Context;
37973797
// Synthesize a call to _undefined() of appropriate type.
3798-
FuncDecl *undefinedDecl = ctx.getUndefinedDecl();
3798+
FuncDecl *undefinedDecl = ctx.getUndefined();
37993799
if (!undefinedDecl) {
38003800
tc.diagnose(E->getLoc(), diag::missing_undefined_runtime);
38013801
return nullptr;

lib/Sema/CodeSynthesis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1804,7 +1804,7 @@ static void synthesizeStubBody(AbstractFunctionDecl *fn, void *) {
18041804
auto *ctor = cast<ConstructorDecl>(fn);
18051805
auto &ctx = ctor->getASTContext();
18061806

1807-
auto unimplementedInitDecl = ctx.getUnimplementedInitializerDecl();
1807+
auto unimplementedInitDecl = ctx.getUnimplementedInitializer();
18081808
auto classDecl = ctor->getDeclContext()->getSelfClassDecl();
18091809
if (!unimplementedInitDecl) {
18101810
ctx.Diags.diagnose(classDecl->getLoc(),

0 commit comments

Comments
 (0)