[llvm] [CaptureTracking][NFC] Clarify usage expectations in PointerMayBeCaptured comments (PR #132744)

via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 14 05:48:03 PDT 2025


================
@@ -41,13 +41,17 @@ namespace llvm {
   /// MaxUsesToExplore specifies how many uses the analysis should explore for
   /// one value before giving up due too "too many uses". If MaxUsesToExplore
   /// is zero, a default value is assumed.
+  /// This assumes the pointer is to a function-local object. The caller is
+  /// responsible for ensuring this.
----------------
Camsyn wrote:

> This depends on the use case. In most cases you'd want to pass a function-local object, but e.g. to infer captures() attribute you'd just work with arbitrary function arguments.
> 
> I think I'd add something like this instead:
> 
> > This function only considers captures of the passed value via its use-def chain, without considering captures of values it may be based on, or implicit captures such as for external globals.

Good point, and thank you for the improved phrasing! Your suggested comment is indeed more appropriate. Just a minor correction: it should be 'def-use chain' rather than 'use-def chain' because our CaptureAnalysis works by forward tracking using `getUser`.

https://github.com/llvm/llvm-project/pull/132744


More information about the llvm-commits mailing list