Skip to content

Commit 3959e06

Browse files
committed
[CaptureTracking][NFC] Clarify usage expectations in PointerMayBeCaptured comments
The comments for PointerMayBeCaptured and related APIs have been updated to explicitly state that these functions assume the input is an function-local object. It is the caller's responsibility to ensure this precondition is met. This clarification aligns with recent discussions and feedback from code reviews, aiming to prevent misuse and potential analysis errors.
1 parent 087e9e4 commit 3959e06

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

llvm/include/llvm/Analysis/CaptureTracking.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,17 @@ namespace llvm {
4141
/// MaxUsesToExplore specifies how many uses the analysis should explore for
4242
/// one value before giving up due too "too many uses". If MaxUsesToExplore
4343
/// is zero, a default value is assumed.
44+
/// This assumes the pointer is to a function-local object. The caller is
45+
/// responsible for ensuring this.
4446
bool PointerMayBeCaptured(const Value *V, bool ReturnCaptures,
4547
unsigned MaxUsesToExplore = 0);
4648

4749
/// Return which components of the pointer may be captured. Only consider
4850
/// components that are part of \p Mask. Once \p StopFn on the accumulated
4951
/// components returns true, the traversal is aborted early. By default, this
5052
/// happens when *any* of the components in \p Mask are captured.
53+
/// This assumes the pointer is to a function-local object. The caller is
54+
/// responsible for ensuring this.
5155
CaptureComponents PointerMayBeCaptured(
5256
const Value *V, bool ReturnCaptures, CaptureComponents Mask,
5357
function_ref<bool(CaptureComponents)> StopFn = capturesAnything,
@@ -64,6 +68,8 @@ namespace llvm {
6468
/// MaxUsesToExplore specifies how many uses the analysis should explore for
6569
/// one value before giving up due too "too many uses". If MaxUsesToExplore
6670
/// is zero, a default value is assumed.
71+
/// This assumes the pointer is to a function-local object. The caller is
72+
/// responsible for ensuring this.
6773
bool PointerMayBeCapturedBefore(const Value *V, bool ReturnCaptures,
6874
const Instruction *I, const DominatorTree *DT,
6975
bool IncludeI = false,
@@ -184,6 +190,8 @@ namespace llvm {
184190
/// MaxUsesToExplore specifies how many uses the analysis should explore for
185191
/// one value before giving up due too "too many uses". If MaxUsesToExplore
186192
/// is zero, a default value is assumed.
193+
/// This assumes the pointer is to a function-local object. The caller is
194+
/// responsible for ensuring this.
187195
void PointerMayBeCaptured(const Value *V, CaptureTracker *Tracker,
188196
unsigned MaxUsesToExplore = 0);
189197

0 commit comments

Comments
 (0)