Skip to content

Commit 28c7d26

Browse files
committed
[AST] Remove SerializedDefaultArgumentInitializer
This stores the same state as DefaultArgumentInitializer, use that instead.
1 parent e3261f6 commit 28c7d26

File tree

7 files changed

+2
-43
lines changed

7 files changed

+2
-43
lines changed

include/swift/AST/DeclContext.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ namespace swift {
7979
class Initializer;
8080
class ClassDecl;
8181
class SerializedAbstractClosureExpr;
82-
class SerializedDefaultArgumentInitializer;
8382
class SerializedTopLevelCodeDecl;
8483
class StructDecl;
8584
class AccessorDecl;
@@ -114,7 +113,6 @@ enum class DeclContextKind : unsigned {
114113
/// \see SerializedLocalDeclContext.
115114
enum class LocalDeclContextKind : uint8_t {
116115
AbstractClosure,
117-
DefaultArgumentInitializer,
118116
TopLevelCodeDecl
119117
};
120118

include/swift/AST/Initializer.h

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -151,29 +151,6 @@ class DefaultArgumentInitializer : public Initializer {
151151
}
152152
};
153153

154-
/// SerializedDefaultArgumentInitializer - This represents what was originally a
155-
/// DefaultArgumentInitializer during serialization. It is preserved only to
156-
/// maintain the correct AST structure and remangling after deserialization.
157-
class SerializedDefaultArgumentInitializer : public SerializedLocalDeclContext {
158-
const unsigned Index;
159-
public:
160-
SerializedDefaultArgumentInitializer(unsigned Index, DeclContext *Parent)
161-
: SerializedLocalDeclContext(LocalDeclContextKind::DefaultArgumentInitializer,
162-
Parent),
163-
Index(Index) {}
164-
165-
unsigned getIndex() const {
166-
return Index;
167-
}
168-
169-
static bool classof(const DeclContext *DC) {
170-
if (auto LDC = dyn_cast<SerializedLocalDeclContext>(DC))
171-
return LDC->getLocalDeclContextKind() ==
172-
LocalDeclContextKind::DefaultArgumentInitializer;
173-
return false;
174-
}
175-
};
176-
177154
/// A property wrapper initialization expression. The parent context is the
178155
/// function or closure which owns the property wrapper.
179156
class PropertyWrapperInitializer : public Initializer {

lib/AST/ASTMangler.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2323,11 +2323,6 @@ void ASTMangler::appendContext(const DeclContext *ctx, StringRef useModuleName)
23232323
case LocalDeclContextKind::AbstractClosure:
23242324
appendClosureEntity(cast<SerializedAbstractClosureExpr>(local));
23252325
return;
2326-
case LocalDeclContextKind::DefaultArgumentInitializer: {
2327-
auto argInit = cast<SerializedDefaultArgumentInitializer>(local);
2328-
appendDefaultArgumentEntity(ctx->getParent(), argInit->getIndex());
2329-
return;
2330-
}
23312326
case LocalDeclContextKind::TopLevelCodeDecl:
23322327
return appendContext(local->getParent(), useModuleName);
23332328
}

lib/AST/DeclContext.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -824,11 +824,6 @@ unsigned DeclContext::printContext(raw_ostream &OS, const unsigned indent,
824824
OS << " closure : " << serializedClosure->getType();
825825
break;
826826
}
827-
case LocalDeclContextKind::DefaultArgumentInitializer: {
828-
auto init = cast<SerializedDefaultArgumentInitializer>(local);
829-
OS << "DefaultArgument index=" << init->getIndex();
830-
break;
831-
}
832827
case LocalDeclContextKind::TopLevelCodeDecl:
833828
OS << " TopLevelCode";
834829
break;

lib/Serialization/Deserialization.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2674,8 +2674,7 @@ Expected<DeclContext *>ModuleFile::getLocalDeclContext(LocalDeclContextID DCID)
26742674
index);
26752675
DeclContext *parent = getDeclContext(parentID);
26762676

2677-
declContextOrOffset = new (ctx)
2678-
SerializedDefaultArgumentInitializer(index, parent);
2677+
declContextOrOffset = new (ctx) DefaultArgumentInitializer(parent, index);
26792678
break;
26802679
}
26812680

lib/Serialization/Serialization.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2499,11 +2499,6 @@ void Serializer::writeASTBlockEntity(const DeclContext *DC) {
24992499
SACE->isImplicit(), SACE->getDiscriminator());
25002500
return;
25012501
}
2502-
case LocalDeclContextKind::DefaultArgumentInitializer: {
2503-
auto DAI = cast<SerializedDefaultArgumentInitializer>(local);
2504-
writeDefaultArgumentInitializer(DAI->getParent(), DAI->getIndex());
2505-
return;
2506-
}
25072502
case LocalDeclContextKind::TopLevelCodeDecl: {
25082503
auto abbrCode = DeclTypeAbbrCodes[TopLevelCodeDeclContextLayout::Code];
25092504
TopLevelCodeDeclContextLayout::emitRecord(Out, ScratchRecord,

test/TypeDecoder/generic_local_types.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class Generic<T> {
186186
// CHECK-DECL: generic_local_types.(file).Generic.<anonymous>.Alias9
187187
// CHECK-DECL: generic_local_types.(file).Generic.<anonymous>.Alias10
188188
// CHECK-DECL: generic_local_types.(file).Generic.<anonymous>.Alias11
189-
// CHECK-DECL: generic_local_types.(file).Generic.method(_:).local context.local context.Alias12
189+
// CHECK-DECL: generic_local_types.(file).Generic.method(_:).default argument initializer.local context.Alias12
190190
// CHECK-DECL: generic_local_types.(file).Generic.method(_:).Alias13
191191
// CHECK-DECL: generic_local_types.(file).Generic.init().Alias14
192192
// CHECK-DECL: generic_local_types.(file).Generic.deinit.Alias15

0 commit comments

Comments
 (0)