[clang] [LifetimeSafety] Support allocating/freeing functions annotated `ownership_takes`/`ownership_returns` (PR #213439)

Balázs Benics via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 6 05:52:03 PST 2026


================
@@ -159,8 +165,10 @@ class AccessPath {
     return dyn_cast<const PlaceholderBase *>(Base);
   }
 
-  const clang::CXXNewExpr *getAsNewAllocation() const {
-    return dyn_cast<const clang::CXXNewExpr *>(Base);
+  /// Returns the allocation expression that created this loan: a
+  /// `CXXNewExpr` or an allocating call.
+  const clang::Expr *getAsAllocation() const {
+    return dyn_cast<const clang::Expr *>(Base);
   }
----------------
steakhal wrote:

That's fine. I figured - I just wanted to let the door open if all the callsites dyncast anyway, then it would be cleaner this way.
I feel more strongly about the comment change, hence that is the suggestion. I feel like singling out `CXXNewExpr` over a plan "call" term felt inequal to me :D

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


More information about the cfe-commits mailing list