@@ -464,13 +464,16 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
464464 SWIFT_INLINE_BITFIELD (SubscriptDecl, VarDecl, 2 ,
465465 StaticSpelling : 2
466466 );
467- SWIFT_INLINE_BITFIELD (AbstractFunctionDecl, ValueDecl, 3 +2 +2 +8 +1 +1 +1 +1 +1 +1 +1 ,
467+ SWIFT_INLINE_BITFIELD (AbstractFunctionDecl, ValueDecl, 3 +2 +2 +2 + 8 +1 +1 +1 +1 +1 +1 +1 ,
468468 // / \see AbstractFunctionDecl::BodyKind
469469 BodyKind : 3 ,
470470
471471 // / \see AbstractFunctionDecl::BodySkippedStatus
472472 BodySkippedStatus : 2 ,
473473
474+ // / \see AbstractFunctionDecl::BodyExpandedStatus
475+ BodyExpandedStatus : 2 ,
476+
474477 // / \see AbstractFunctionDecl::SILSynthesizeKind
475478 SILSynthesizeKind : 2 ,
476479
@@ -7003,6 +7006,19 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
70037006 // This enum needs to fit in a 2-bit bitfield.
70047007 };
70057008
7009+ enum class BodyExpandedStatus {
7010+ // / We haven't tried to expand any body macros.
7011+ NotExpanded,
7012+
7013+ // / We tried to expand body macros, and there weren't any.
7014+ NoMacros,
7015+
7016+ // / The body was expanded from a body macro.
7017+ Expanded,
7018+
7019+ // This enum needs to fit in a 2-bit bitfield.
7020+ };
7021+
70067022 BodyKind getBodyKind () const {
70077023 return BodyKind (Bits.AbstractFunctionDecl .BodyKind );
70087024 }
@@ -7089,6 +7105,7 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
70897105 ValueDecl (Kind, Parent, Name, NameLoc), BodyAndFP(), AsyncLoc(AsyncLoc),
70907106 ThrowsLoc(ThrowsLoc), ThrownType(ThrownTy) {
70917107 setBodyKind (BodyKind::None);
7108+ setBodyExpandedStatus (BodyExpandedStatus::NotExpanded);
70927109 Bits.AbstractFunctionDecl .HasImplicitSelfDecl = HasImplicitSelfDecl;
70937110 Bits.AbstractFunctionDecl .Overridden = false ;
70947111 Bits.AbstractFunctionDecl .Async = Async;
@@ -7110,6 +7127,14 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
71107127 Bits.AbstractFunctionDecl .BodySkippedStatus = unsigned (status);
71117128 }
71127129
7130+ BodyExpandedStatus getBodyExpandedStatus () const {
7131+ return BodyExpandedStatus (Bits.AbstractFunctionDecl .BodyExpandedStatus );
7132+ }
7133+
7134+ void setBodyExpandedStatus (BodyExpandedStatus status) {
7135+ Bits.AbstractFunctionDecl .BodyExpandedStatus = unsigned (status);
7136+ }
7137+
71137138 void setSILSynthesizeKind (SILSynthesizeKind K) {
71147139 Bits.AbstractFunctionDecl .SILSynthesizeKind = unsigned (K);
71157140 }
@@ -7258,6 +7283,10 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
72587283 // / \sa hasBody()
72597284 BraceStmt *getBody (bool canSynthesize = true ) const ;
72607285
7286+ // / Retrieve the body after macro expansion, which might also have been
7287+ // / type-checked.
7288+ BraceStmt *getMacroExpandedBody () const ;
7289+
72617290 // / Retrieve the type-checked body of the given function, or \c nullptr if
72627291 // / there's no body available.
72637292 BraceStmt *getTypecheckedBody () const ;
0 commit comments