================ @@ -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())) + return RetCC; + return CaptureComponents::None; + } + + /// Use U directly captures CI.getOtherComponents() and additionally + /// CI.getRetComponents() through the return value of the user of U. + /// + /// Return std::nullopt to stop the traversal, or the CaptureComponents to + /// follow via the return value, which must be a subset of + /// CI.getRetComponents(). + /// + /// For convenience, prefer returning one of stop(), continueDefault(CI) or + /// continueIgnoringReturn(). + virtual std::optional<CaptureComponents> captured(const Use *U, + CaptureInfo CI) = 0; ---------------- nikic wrote:
Done. I think it's nicer now. https://github.com/llvm/llvm-project/pull/125880 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits