[clang] [llvm] [CaptureTracking][FunctionAttrs] Add support for CaptureInfo (PR #125880)
Nikita Popov via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 7 01:25:55 PST 2025
================
@@ -94,31 +96,53 @@ namespace llvm {
/// U->getUser() is always an Instruction.
virtual bool shouldExplore(const Use *U);
- /// captured - Information about the pointer was captured by the user of
- /// use U. Return true to stop the traversal or false to continue looking
- /// for more capturing instructions.
- virtual bool captured(const Use *U) = 0;
+ /// When returned from captures(), stop the traversal.
+ static std::optional<CaptureComponents> stop() { return std::nullopt; }
+
+ /// When returned from captures(), continue traversal, but do not follow
+ /// the return value of this user, even if it has additional capture
+ /// components. Should only be used if captures() has already taken the
+ /// potential return caputres into account.
+ static std::optional<CaptureComponents> continueIgnoringReturn() {
+ return CaptureComponents::None;
+ }
+
+ /// When returned from captures(), continue traversal, and also follow
+ /// the return value of this user if it has additional capture components
+ /// (that is, capture components in Ret that are not part of Other).
+ static std::optional<CaptureComponents> continueDefault(CaptureInfo CI) {
+ CaptureComponents RetCC = CI.getRetComponents();
+ if (!capturesNothing(RetCC & ~CI.getOtherComponents()))
----------------
nikic wrote:
I've switched most places using !capturesNothing to capturesAnything now.
https://github.com/llvm/llvm-project/pull/125880
More information about the cfe-commits
mailing list