[clang] [llvm] [LifetimeSafety] Add lifetimebound inference for std::make_unique (PR #191632)
Gábor Horváth via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 16 02:03:45 PDT 2026
================
@@ -221,6 +221,17 @@ void Sema::inferGslOwnerPointerAttribute(CXXRecordDecl *Record) {
inferGslPointerAttribute(Record, Record);
}
+static const CXXNewExpr *findCXXNewExpr(const Stmt *S) {
+ if (!S)
+ return nullptr;
+ if (const auto *E = dyn_cast<CXXNewExpr>(S))
+ return E;
+ for (const Stmt *Child : S->children())
+ if (const CXXNewExpr *E = findCXXNewExpr(Child))
----------------
Xazax-hun wrote:
Usually, we try to avoid recursion when we can to avoid exhausting the stack but here it is probably fine since this is only used for `make_unique` that supposed to have a relatively small AST. I wonder if we should have a comment to make sure this does not get used for something else without getting rid of the recursion.
https://github.com/llvm/llvm-project/pull/191632
More information about the cfe-commits
mailing list