[clang] [-Wunsafe-buffer-usage][NFC] Move the cast check for data() call into `DataInvocationGadget` (PR #234814)

Yu Hao via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 10 12:49:26 PST 2026


================
@@ -2447,6 +2442,32 @@ class DataInvocationGadget : public WarningGadget {
     return false;
   }
 
+  // Returns true if `CE` casts the pointer returned by `data()` to a pointer to
+  // a larger type, or if the size of either pointee type cannot be determined.
+  static bool isUnsafeCast(const ExplicitCastExpr *CE, const ASTContext &Ctx) {
----------------
yuhaouy wrote:

Done.

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


More information about the cfe-commits mailing list