Skip to content

Commit 2f2b8af

Browse files
committed
Remove the list of synthesized decls"
This used to be a lot more relevant a long time ago when typeCheckFunctionsAndExternalDecls actually did type check external functions defined in C. Now, it serves no purpose. The validation order change from just type checking these things eagerly doesn't seem to affect anything.
1 parent 0a262fc commit 2f2b8af

8 files changed

+5
-30
lines changed

include/swift/AST/ASTContext.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -553,10 +553,6 @@ class ASTContext final {
553553
ForeignLanguage language,
554554
const DeclContext *dc);
555555

556-
/// Add a declaration that was synthesized to a per-source file list if
557-
/// if is part of a source file.
558-
void addSynthesizedDecl(Decl *decl);
559-
560556
/// Add a cleanup function to be called when the ASTContext is deallocated.
561557
void addCleanup(std::function<void(void)> cleanup);
562558

lib/AST/ASTContext.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,12 +1366,6 @@ bool ASTContext::hasArrayLiteralIntrinsics() const {
13661366
&& getDeallocateUninitializedArray();
13671367
}
13681368

1369-
void ASTContext::addSynthesizedDecl(Decl *decl) {
1370-
auto *fileUnit = decl->getDeclContext()->getModuleScopeContext();
1371-
if (auto *sf = dyn_cast<SourceFile>(fileUnit))
1372-
sf->SynthesizedDecls.push_back(decl);
1373-
}
1374-
13751369
void ASTContext::addCleanup(std::function<void(void)> cleanup) {
13761370
getImpl().Cleanups.push_back(std::move(cleanup));
13771371
}

lib/Sema/DerivedConformanceCodable.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -741,9 +741,8 @@ static FuncDecl *deriveEncodable_encode(DerivedConformance &derived) {
741741
encodeDecl->copyFormalAccessFrom(derived.Nominal,
742742
/*sourceIsParentContext*/ true);
743743

744-
C.addSynthesizedDecl(encodeDecl);
745-
746744
derived.addMembersToConformanceContext({encodeDecl});
745+
747746
return encodeDecl;
748747
}
749748

@@ -1019,9 +1018,8 @@ static ValueDecl *deriveDecodable_init(DerivedConformance &derived) {
10191018
initDecl->copyFormalAccessFrom(derived.Nominal,
10201019
/*sourceIsParentContext*/ true);
10211020

1022-
C.addSynthesizedDecl(initDecl);
1023-
10241021
derived.addMembersToConformanceContext({initDecl});
1022+
10251023
return initDecl;
10261024
}
10271025

lib/Sema/DerivedConformanceCodingKey.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,8 @@ static ValueDecl *deriveInitDecl(DerivedConformance &derived, Type paramType,
145145

146146
initDecl->setAccess(derived.Nominal->getFormalAccess());
147147

148-
C.addSynthesizedDecl(initDecl);
149-
150148
derived.addMembersToConformanceContext({initDecl});
149+
151150
return initDecl;
152151
}
153152

@@ -176,9 +175,7 @@ static ValueDecl *deriveProperty(DerivedConformance &derived, Type type,
176175
// Synthesize the body.
177176
synthesizer(getterDecl);
178177

179-
auto *dc = cast<IterableDeclContext>(derived.ConformanceDecl);
180-
dc->addMember(propDecl);
181-
dc->addMember(pbDecl);
178+
derived.addMembersToConformanceContext({propDecl, pbDecl});
182179
return propDecl;
183180
}
184181

lib/Sema/DerivedConformanceEquatableHashable.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -769,8 +769,6 @@ deriveEquatable_eq(
769769

770770
eqDecl->copyFormalAccessFrom(derived.Nominal, /*sourceIsParentContext*/ true);
771771

772-
C.addSynthesizedDecl(eqDecl);
773-
774772
// Add the operator to the parent scope.
775773
derived.addMembersToConformanceContext({eqDecl});
776774

@@ -890,9 +888,8 @@ deriveHashable_hashInto(
890888

891889
hashDecl->copyFormalAccessFrom(derived.Nominal);
892890

893-
C.addSynthesizedDecl(hashDecl);
894-
895891
derived.addMembersToConformanceContext({hashDecl});
892+
896893
return hashDecl;
897894
}
898895

@@ -1253,8 +1250,6 @@ static ValueDecl *deriveHashable_hashValue(DerivedConformance &derived) {
12531250
auto *patDecl = PatternBindingDecl::createImplicit(
12541251
C, StaticSpellingKind::None, hashValuePat, /*InitExpr*/ nullptr,
12551252
parentDC);
1256-
C.addSynthesizedDecl(hashValueDecl);
1257-
C.addSynthesizedDecl(getterDecl);
12581253

12591254
derived.addMembersToConformanceContext({hashValueDecl, patDecl});
12601255
return hashValueDecl;

lib/Sema/DerivedConformanceRawRepresentable.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,6 @@ deriveRawRepresentable_init(DerivedConformance &derived) {
434434
// an instance without function call overhead.
435435
maybeMarkAsInlinable(derived, initDecl);
436436

437-
C.addSynthesizedDecl(initDecl);
438-
439437
derived.addMembersToConformanceContext({initDecl});
440438
return initDecl;
441439
}

lib/Sema/DerivedConformances.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,6 @@ DerivedConformance::declareDerivedPropertyGetter(VarDecl *property,
311311

312312
getterDecl->copyFormalAccessFrom(property);
313313

314-
C.addSynthesizedDecl(getterDecl);
315314

316315
return getterDecl;
317316
}

lib/Sema/TypeChecker.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,6 @@ static void typeCheckFunctionsAndExternalDecls(SourceFile &SF, TypeChecker &TC)
318318
} while (currentFunctionIdx < TC.definedFunctions.size() ||
319319
currentSynthesizedDecl < SF.SynthesizedDecls.size());
320320

321-
// FIXME: Horrible hack. Store this somewhere more appropriate.
322-
SF.LastCheckedSynthesizedDecl = currentSynthesizedDecl;
323321

324322
// Compute captures for functions and closures we visited.
325323
for (auto *closure : TC.ClosuresWithUncomputedCaptures) {

0 commit comments

Comments
 (0)