Skip to content

Commit 8adf340

Browse files
committed
Make addImplicitConstructors a static method
1 parent 7837876 commit 8adf340

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

lib/Sema/CodeSynthesis.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ static bool areAllStoredPropertiesDefaultInitializable(NominalTypeDecl *decl) {
833833
return true;
834834
}
835835

836-
static void addImplicitConstructorsToStruct(StructDecl *decl, ASTContext &ctx) {
836+
static void addImplicitConstructorsToStruct(StructDecl *decl) {
837837
assert(!decl->hasClangNode() &&
838838
"ClangImporter is responsible for adding implicit constructors");
839839
assert(!decl->hasUnreferenceableStorage() &&
@@ -884,6 +884,7 @@ static void addImplicitConstructorsToStruct(StructDecl *decl, ASTContext &ctx) {
884884

885885
if (FoundMemberwiseInitializedProperty) {
886886
// Create the implicit memberwise constructor.
887+
auto &ctx = decl->getASTContext();
887888
auto ctor = createImplicitConstructor(
888889
decl, ImplicitConstructorKind::Memberwise, ctx);
889890
decl->addMember(ctor);
@@ -893,7 +894,7 @@ static void addImplicitConstructorsToStruct(StructDecl *decl, ASTContext &ctx) {
893894
TypeChecker::defineDefaultConstructor(decl);
894895
}
895896

896-
static void addImplicitConstructorsToClass(ClassDecl *decl, ASTContext &ctx) {
897+
static void addImplicitConstructorsToClass(ClassDecl *decl) {
897898
// Bail out if we're validating one of our constructors already;
898899
// we'll revisit the issue later.
899900
if (!decl->hasClangNode()) {
@@ -911,6 +912,7 @@ static void addImplicitConstructorsToClass(ClassDecl *decl, ASTContext &ctx) {
911912
// variable.
912913
bool FoundDesignatedInit = false;
913914

915+
auto &ctx = decl->getASTContext();
914916
SmallVector<std::pair<ValueDecl *, Type>, 4> declaredInitializers;
915917
llvm::SmallPtrSet<ConstructorDecl *, 4> overriddenInits;
916918
if (decl->hasClangNode()) {
@@ -1104,9 +1106,9 @@ void TypeChecker::addImplicitConstructors(NominalTypeDecl *decl) {
11041106
}
11051107

11061108
if (auto *structDecl = dyn_cast<StructDecl>(decl))
1107-
addImplicitConstructorsToStruct(structDecl, Context);
1109+
addImplicitConstructorsToStruct(structDecl);
11081110
if (auto *classDecl = dyn_cast<ClassDecl>(decl))
1109-
addImplicitConstructorsToClass(classDecl, Context);
1111+
addImplicitConstructorsToClass(classDecl);
11101112
}
11111113

11121114
void TypeChecker::synthesizeMemberForLookup(NominalTypeDecl *target,

lib/Sema/TypeCheckDecl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2783,7 +2783,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
27832783
// Force lowering of stored properties.
27842784
(void) SD->getStoredProperties();
27852785

2786-
TC.addImplicitConstructors(SD);
2786+
TypeChecker::addImplicitConstructors(SD);
27872787

27882788
for (Decl *Member : SD->getMembers())
27892789
visit(Member);
@@ -4408,7 +4408,7 @@ EmittedMembersRequest::evaluate(Evaluator &evaluator,
44084408

44094409
// We need to add implicit initializers because they
44104410
// affect vtable layout.
4411-
TC.addImplicitConstructors(CD);
4411+
TypeChecker::addImplicitConstructors(CD);
44124412

44134413
auto forceConformance = [&](ProtocolDecl *protocol) {
44144414
if (auto ref = TypeChecker::conformsToProtocol(

lib/Sema/TypeChecker.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,7 @@ class TypeChecker final : public LazyResolver {
11121112
///
11131113
/// Add any implicitly-defined constructors required for the given
11141114
/// struct or class.
1115-
void addImplicitConstructors(NominalTypeDecl *typeDecl);
1115+
static void addImplicitConstructors(NominalTypeDecl *typeDecl);
11161116

11171117
/// Synthesize the member with the given name on the target if applicable,
11181118
/// i.e. if the member is synthesizable and has not yet been added to the

0 commit comments

Comments
 (0)