@@ -41,9 +41,12 @@ template <> struct DenseMapInfo<swift::CapturedValue>;
4141namespace swift {
4242class ValueDecl ;
4343class FuncDecl ;
44+ class Expr ;
4445class OpaqueValueExpr ;
46+ class PackElementExpr ;
4547class VarDecl ;
4648class GenericEnvironment ;
49+ class Type ;
4750
4851// / CapturedValue includes both the declaration being captured, along with flags
4952// / that indicate how it is captured.
@@ -52,7 +55,7 @@ class CapturedValue {
5255
5356public:
5457 using Storage =
55- llvm::PointerIntPair<llvm::PointerUnion<ValueDecl*, OpaqueValueExpr *>, 2 ,
58+ llvm::PointerIntPair<llvm::PointerUnion<ValueDecl *, Expr *>, 2 ,
5659 unsigned >;
5760
5861private:
@@ -78,15 +81,7 @@ class CapturedValue {
7881 CapturedValue (ValueDecl *Val, unsigned Flags, SourceLoc Loc)
7982 : Value(Val, Flags), Loc(Loc) {}
8083
81- private:
82- // This is only used in TypeLowering when forming Lowered Capture
83- // Info. OpaqueValueExpr captured value should never show up in the AST
84- // itself.
85- //
86- // NOTE: AbstractClosureExpr::getIsolationCrossing relies upon this and
87- // asserts that it never sees one of these.
88- explicit CapturedValue (OpaqueValueExpr *Val, unsigned Flags)
89- : Value(Val, Flags), Loc(SourceLoc()) {}
84+ CapturedValue (Expr *Val, unsigned Flags);
9085
9186public:
9287 static CapturedValue getDynamicSelfMetadata () {
@@ -97,10 +92,14 @@ class CapturedValue {
9792 bool isNoEscape () const { return Value.getInt () & IsNoEscape; }
9893
9994 bool isDynamicSelfMetadata () const { return !Value.getPointer (); }
100- bool isOpaqueValue () const {
101- return Value.getPointer ().is <OpaqueValueExpr *>();
95+
96+ bool isExpr () const {
97+ return Value.getPointer ().dyn_cast <Expr *>();
10298 }
10399
100+ bool isPackElement () const ;
101+ bool isOpaqueValue () const ;
102+
104103 // / Returns true if this captured value is a local capture.
105104 // /
106105 // / NOTE: This implies that the value is not dynamic self metadata, since
@@ -116,17 +115,19 @@ class CapturedValue {
116115 }
117116
118117 ValueDecl *getDecl () const {
119- assert (Value.getPointer () && " dynamic Self metadata capture does not "
120- " have a value" );
121118 return Value.getPointer ().dyn_cast <ValueDecl *>();
122119 }
123120
124- OpaqueValueExpr *getOpaqueValue () const {
125- assert (Value.getPointer () && " dynamic Self metadata capture does not "
126- " have a value" );
127- return Value.getPointer ().dyn_cast <OpaqueValueExpr *>();
121+ Expr *getExpr () const {
122+ return Value.getPointer ().dyn_cast <Expr *>();
128123 }
129124
125+ OpaqueValueExpr *getOpaqueValue () const ;
126+
127+ PackElementExpr *getPackElement () const ;
128+
129+ Type getPackElementType () const ;
130+
130131 SourceLoc getLoc () const { return Loc; }
131132
132133 unsigned getFlags () const { return Value.getInt (); }
0 commit comments