@@ -311,55 +311,64 @@ inline bool capturesFullProvenance(CaptureComponents CC) {
311
311
312
312
raw_ostream &operator <<(raw_ostream &OS, CaptureComponents CC);
313
313
314
- // / Represents which components of the pointer may be captured and whether
315
- // / the capture is via the return value only. This represents the captures(...)
316
- // / attribute in IR.
314
+ // / Represents which components of the pointer may be captured in which
315
+ // / location. This represents the captures(...) attribute in IR.
317
316
// /
318
317
// / For more information on the precise semantics see LangRef.
319
318
class CaptureInfo {
320
- CaptureComponents Components ;
321
- bool ReturnOnly ;
319
+ CaptureComponents OtherComponents ;
320
+ CaptureComponents RetComponents ;
322
321
323
322
public:
324
- CaptureInfo (CaptureComponents Components, bool ReturnOnly = false )
325
- : Components(Components),
326
- ReturnOnly (capturesAnything(Components) && ReturnOnly) {}
323
+ CaptureInfo (CaptureComponents OtherComponents,
324
+ CaptureComponents RetComponents)
325
+ : OtherComponents(OtherComponents), RetComponents(RetComponents) {}
326
+
327
+ CaptureInfo (CaptureComponents Components)
328
+ : OtherComponents(Components), RetComponents(Components) {}
327
329
328
330
// / Create CaptureInfo that may capture all components of the pointer.
329
331
static CaptureInfo all () { return CaptureInfo (CaptureComponents::All); }
330
332
331
- // / Get the potentially captured components of the pointer.
332
- operator CaptureComponents () const { return Components; }
333
+ // / Get components potentially captured by the return value.
334
+ CaptureComponents getRetComponents () const { return RetComponents; }
335
+
336
+ // / Get components potentially captured through locations other than the
337
+ // / return value.
338
+ CaptureComponents getOtherComponents () const { return OtherComponents; }
333
339
334
- // / Whether the pointer is captured through the return value only.
335
- bool isReturnOnly () const { return ReturnOnly; }
340
+ // / Get the potentially captured components of the pointer (regardless of
341
+ // / location).
342
+ operator CaptureComponents () const { return OtherComponents | RetComponents; }
336
343
337
344
bool operator ==(CaptureInfo Other) const {
338
- return Components == Other.Components && ReturnOnly == Other.ReturnOnly ;
345
+ return OtherComponents == Other.OtherComponents &&
346
+ RetComponents == Other.RetComponents ;
339
347
}
340
348
341
349
bool operator !=(CaptureInfo Other) const { return !(*this == Other); }
342
350
343
351
// / Compute union of CaptureInfos.
344
352
CaptureInfo operator |(CaptureInfo Other) const {
345
- return CaptureInfo (Components | Other.Components ,
346
- ReturnOnly && Other.ReturnOnly );
353
+ return CaptureInfo (OtherComponents | Other.OtherComponents ,
354
+ RetComponents | Other.RetComponents );
347
355
}
348
356
349
357
// / Compute intersection of CaptureInfos.
350
358
CaptureInfo operator &(CaptureInfo Other) const {
351
- return CaptureInfo (Components & Other.Components ,
352
- ReturnOnly || Other.ReturnOnly );
359
+ return CaptureInfo (OtherComponents & Other.OtherComponents ,
360
+ RetComponents & Other.RetComponents );
353
361
}
354
362
355
363
static CaptureInfo createFromIntValue (uint32_t Data) {
356
- return CaptureInfo (CaptureComponents (Data >> 1 ), Data & 1 );
364
+ return CaptureInfo (CaptureComponents (Data >> 4 ),
365
+ CaptureComponents (Data & 0xf ));
357
366
}
358
367
359
368
// / Convert CaptureInfo into an encoded integer value (used by captures
360
369
// / attribute).
361
370
uint32_t toIntValue () const {
362
- return (uint32_t (Components ) << 1 ) | ReturnOnly ;
371
+ return (uint32_t (OtherComponents ) << 4 ) | uint32_t (RetComponents) ;
363
372
}
364
373
};
365
374
0 commit comments