@@ -41,9 +41,12 @@ template <> struct DenseMapInfo<swift::CapturedValue>;
41
41
namespace swift {
42
42
class ValueDecl ;
43
43
class FuncDecl ;
44
+ class Expr ;
44
45
class OpaqueValueExpr ;
46
+ class PackElementExpr ;
45
47
class VarDecl ;
46
48
class GenericEnvironment ;
49
+ class Type ;
47
50
48
51
// / CapturedValue includes both the declaration being captured, along with flags
49
52
// / that indicate how it is captured.
@@ -52,7 +55,7 @@ class CapturedValue {
52
55
53
56
public:
54
57
using Storage =
55
- llvm::PointerIntPair<llvm::PointerUnion<ValueDecl*, OpaqueValueExpr *>, 2 ,
58
+ llvm::PointerIntPair<llvm::PointerUnion<ValueDecl *, Expr *>, 2 ,
56
59
unsigned >;
57
60
58
61
private:
@@ -78,15 +81,7 @@ class CapturedValue {
78
81
CapturedValue (ValueDecl *Val, unsigned Flags, SourceLoc Loc)
79
82
: Value(Val, Flags), Loc(Loc) {}
80
83
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);
90
85
91
86
public:
92
87
static CapturedValue getDynamicSelfMetadata () {
@@ -97,10 +92,14 @@ class CapturedValue {
97
92
bool isNoEscape () const { return Value.getInt () & IsNoEscape; }
98
93
99
94
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 *>();
102
98
}
103
99
100
+ bool isPackElement () const ;
101
+ bool isOpaqueValue () const ;
102
+
104
103
// / Returns true if this captured value is a local capture.
105
104
// /
106
105
// / NOTE: This implies that the value is not dynamic self metadata, since
@@ -116,17 +115,19 @@ class CapturedValue {
116
115
}
117
116
118
117
ValueDecl *getDecl () const {
119
- assert (Value.getPointer () && " dynamic Self metadata capture does not "
120
- " have a value" );
121
118
return Value.getPointer ().dyn_cast <ValueDecl *>();
122
119
}
123
120
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 *>();
128
123
}
129
124
125
+ OpaqueValueExpr *getOpaqueValue () const ;
126
+
127
+ PackElementExpr *getPackElement () const ;
128
+
129
+ Type getPackElementType () const ;
130
+
130
131
SourceLoc getLoc () const { return Loc; }
131
132
132
133
unsigned getFlags () const { return Value.getInt (); }
0 commit comments