@@ -311,55 +311,64 @@ inline bool capturesFullProvenance(CaptureComponents CC) {
311311
312312raw_ostream &operator <<(raw_ostream &OS, CaptureComponents CC);
313313
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.
317316// /
318317// / For more information on the precise semantics see LangRef.
319318class CaptureInfo {
320- CaptureComponents Components ;
321- bool ReturnOnly ;
319+ CaptureComponents OtherComponents ;
320+ CaptureComponents RetComponents ;
322321
323322public:
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) {}
327329
328330 // / Create CaptureInfo that may capture all components of the pointer.
329331 static CaptureInfo all () { return CaptureInfo (CaptureComponents::All); }
330332
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; }
333339
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; }
336343
337344 bool operator ==(CaptureInfo Other) const {
338- return Components == Other.Components && ReturnOnly == Other.ReturnOnly ;
345+ return OtherComponents == Other.OtherComponents &&
346+ RetComponents == Other.RetComponents ;
339347 }
340348
341349 bool operator !=(CaptureInfo Other) const { return !(*this == Other); }
342350
343351 // / Compute union of CaptureInfos.
344352 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 );
347355 }
348356
349357 // / Compute intersection of CaptureInfos.
350358 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 );
353361 }
354362
355363 static CaptureInfo createFromIntValue (uint32_t Data) {
356- return CaptureInfo (CaptureComponents (Data >> 1 ), Data & 1 );
364+ return CaptureInfo (CaptureComponents (Data >> 4 ),
365+ CaptureComponents (Data & 0xf ));
357366 }
358367
359368 // / Convert CaptureInfo into an encoded integer value (used by captures
360369 // / attribute).
361370 uint32_t toIntValue () const {
362- return (uint32_t (Components ) << 1 ) | ReturnOnly ;
371+ return (uint32_t (OtherComponents ) << 4 ) | uint32_t (RetComponents) ;
363372 }
364373};
365374
0 commit comments