Skip to content

Commit a73bc7b

Browse files
committed
AST: Add AbstractFunctionDecl::isSynthesized() flag
1 parent c12a25d commit a73bc7b

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

include/swift/AST/Decl.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ class alignas(1 << DeclAlignInBits) Decl {
367367
DefaultArgumentResilienceExpansion : 1
368368
);
369369

370-
SWIFT_INLINE_BITFIELD(AbstractFunctionDecl, ValueDecl, 3+8+5+1+1+1+1+1,
370+
SWIFT_INLINE_BITFIELD(AbstractFunctionDecl, ValueDecl, 3+8+5+1+1+1+1+1+1,
371371
/// \see AbstractFunctionDecl::BodyKind
372372
BodyKind : 3,
373373

@@ -390,7 +390,11 @@ class alignas(1 << DeclAlignInBits) Decl {
390390
HasComputedNeedsNewVTableEntry : 1,
391391

392392
/// The ResilienceExpansion to use for default arguments.
393-
DefaultArgumentResilienceExpansion : 1
393+
DefaultArgumentResilienceExpansion : 1,
394+
395+
/// Whether this member was synthesized as part of a derived
396+
/// protocol conformance.
397+
Synthesized : 1
394398
);
395399

396400
SWIFT_INLINE_BITFIELD(FuncDecl, AbstractFunctionDecl, 1+2+1+1+2,
@@ -5253,6 +5257,14 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
52535257
return Bits.AbstractFunctionDecl.NeedsNewVTableEntry;
52545258
}
52555259

5260+
bool isSynthesized() const {
5261+
return Bits.AbstractFunctionDecl.Synthesized;
5262+
}
5263+
5264+
void setSynthesized(bool value = true) {
5265+
Bits.AbstractFunctionDecl.Synthesized = value;
5266+
}
5267+
52565268
private:
52575269
void computeNeedsNewVTableEntry();
52585270

lib/Sema/DerivedConformanceCodable.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,7 @@ static FuncDecl *deriveEncodable_encode(TypeChecker &tc, Decl *parentDecl,
750750
TypeLoc::withoutLoc(returnType),
751751
target);
752752
encodeDecl->setImplicit();
753+
encodeDecl->setSynthesized();
753754
encodeDecl->setBodySynthesizer(deriveBodyEncodable_encode);
754755

755756
// This method should be marked as 'override' for classes inheriting Encodable
@@ -1084,6 +1085,7 @@ static ValueDecl *deriveDecodable_init(TypeChecker &tc, Decl *parentDecl,
10841085
SourceLoc(), selfDecl, paramList,
10851086
/*GenericParams=*/nullptr, target);
10861087
initDecl->setImplicit();
1088+
initDecl->setSynthesized();
10871089
initDecl->setBodySynthesizer(deriveBodyDecodable_init);
10881090

10891091
// This constructor should be marked as `required` for non-final classes.

0 commit comments

Comments
 (0)