[clang] [clang][-Wunsafe-buffer-usage] Warn on annotated unsafe container construction (PR #227108)

Yitzhak Mandelbaum via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 1 06:04:01 PDT 2026


================
@@ -503,8 +503,8 @@ static const Expr *getSubExprInSizeOfExpr(const Expr &E) {
 // Providing that `Ptr` is a pointer and `Size` is an unsigned-integral
 // expression, returns true iff they follow one of the following safe
 // patterns:
-//  1. Ptr is `DRE.data()` and Size is `DRE.size()`, where DRE is a hardened
-//     container or view;
+//  1. Ptr is `DRE.data()` and Size is `DRE.size()` (or `DRE.size_bytes()` for
+//     char pointers), called on the same container or view object `DRE`;
----------------
ymand wrote:

In looking at the diff, I see we're losing the fidelity of "hardened" container/view. I think this is ok (because even hardened container/views currently admit bad pointer-size pairs, exactly what we're trying to cut down on), but just wanted to call out this tradeoff.

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


More information about the cfe-commits mailing list