[clang] [Clang][-Wunsafe-buffer-usage] Allow safe form of libc memset. (PR #178107)

Rohan Jacob-Rao via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 27 14:51:19 PST 2026


================
@@ -800,6 +800,50 @@ static bool isNullTermPointer(const Expr *Ptr, ASTContext &Ctx) {
   return false;
 }
 
+// Given an expression like `&x` or `std::addressof(x)`, returns the
+// `DeclRefExpr` corresponding to `x`. Returns null if the expression `E` is not
+// an address-of expression.
+static const DeclRefExpr *getDeclRefInAddressOfExpr(const Expr *E) {
----------------
rohanjr wrote:

It seems your comment is still valid, i.e. we could use the helper function to look for an address-of expression. I refactored the helper so it can be used easily in `IsPtrBufferSafe` (see last commit), but I think the change to `isPtrBufferSafe` should be in a separate PR in case it accidentally changes behavior / needs to be rolled back.

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


More information about the cfe-commits mailing list