@@ -43,6 +43,7 @@ class ValueDecl;
4343class FuncDecl ;
4444class OpaqueValueExpr ;
4545class VarDecl ;
46+ class GenericEnvironment ;
4647
4748// / CapturedValue includes both the declaration being captured, along with flags
4849// / that indicate how it is captured.
@@ -140,19 +141,27 @@ class DynamicSelfType;
140141// / Stores information about captured variables.
141142class CaptureInfo {
142143 class CaptureInfoStorage final
143- : public llvm::TrailingObjects<CaptureInfoStorage, CapturedValue> {
144+ : public llvm::TrailingObjects<CaptureInfoStorage,
145+ CapturedValue,
146+ GenericEnvironment *> {
144147
145148 DynamicSelfType *DynamicSelf;
146149 OpaqueValueExpr *OpaqueValue;
147- unsigned Count;
150+ unsigned NumCapturedValues;
151+ unsigned NumGenericEnvironments;
152+
148153 public:
149- explicit CaptureInfoStorage (unsigned count, DynamicSelfType *dynamicSelf,
150- OpaqueValueExpr *opaqueValue)
151- : DynamicSelf(dynamicSelf), OpaqueValue(opaqueValue), Count(count) { }
154+ explicit CaptureInfoStorage (DynamicSelfType *dynamicSelf,
155+ OpaqueValueExpr *opaqueValue,
156+ unsigned numCapturedValues,
157+ unsigned numGenericEnvironments)
158+ : DynamicSelf(dynamicSelf), OpaqueValue(opaqueValue),
159+ NumCapturedValues(numCapturedValues),
160+ NumGenericEnvironments(numGenericEnvironments) { }
152161
153- ArrayRef<CapturedValue> getCaptures () const {
154- return llvm::ArrayRef ( this -> getTrailingObjects <CapturedValue>(), Count);
155- }
162+ ArrayRef<CapturedValue> getCaptures () const ;
163+
164+ ArrayRef<GenericEnvironment *> getGenericEnvironments () const ;
156165
157166 DynamicSelfType *getDynamicSelfType () const {
158167 return DynamicSelf;
@@ -161,6 +170,10 @@ class CaptureInfo {
161170 OpaqueValueExpr *getOpaqueValue () const {
162171 return OpaqueValue;
163172 }
173+
174+ unsigned numTrailingObjects (OverloadToken<CapturedValue>) const {
175+ return NumCapturedValues;
176+ }
164177 };
165178
166179 enum class Flags : unsigned {
@@ -173,9 +186,11 @@ class CaptureInfo {
173186public:
174187 // / The default-constructed CaptureInfo is "not yet computed".
175188 CaptureInfo () = default ;
176- CaptureInfo (ASTContext &ctx, ArrayRef<CapturedValue> captures,
189+ CaptureInfo (ASTContext &ctx,
190+ ArrayRef<CapturedValue> captures,
177191 DynamicSelfType *dynamicSelf, OpaqueValueExpr *opaqueValue,
178- bool genericParamCaptures);
192+ bool genericParamCaptures,
193+ ArrayRef<GenericEnvironment *> genericEnv=ArrayRef<GenericEnvironment*>());
179194
180195 // / A CaptureInfo representing no captures at all.
181196 static CaptureInfo empty ();
@@ -189,6 +204,7 @@ class CaptureInfo {
189204 !hasDynamicSelfCapture () && !hasOpaqueValueCapture ();
190205 }
191206
207+ // / Returns all captured values and opaque expressions.
192208 ArrayRef<CapturedValue> getCaptures () const {
193209 // FIXME: Ideally, everywhere that synthesizes a function should include
194210 // its capture info.
@@ -206,7 +222,14 @@ class CaptureInfo {
206222 // / \returns true if getLocalCaptures() will return a non-empty list.
207223 bool hasLocalCaptures () const ;
208224
209- // / \returns true if the function captures any generic type parameters.
225+ // / Returns all captured pack element environments.
226+ ArrayRef<GenericEnvironment *> getGenericEnvironments () const {
227+ assert (hasBeenComputed ());
228+ return StorageAndFlags.getPointer ()->getGenericEnvironments ();
229+ }
230+
231+ // / \returns true if the function captures the primary generic environment
232+ // / from its innermost declaration context.
210233 bool hasGenericParamCaptures () const {
211234 // FIXME: Ideally, everywhere that synthesizes a function should include
212235 // its capture info.
0 commit comments