[clang] [-Wunsafe-buffer-usage] Ignore constant safe indices in array subscripts (PR #80504)

via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 14 16:02:51 PST 2024


================
@@ -598,16 +623,16 @@ class ArraySubscriptGadget : public WarningGadget {
   }
 
   static Matcher matcher() {
-    // FIXME: What if the index is integer literal 0? Should this be
-    // a safe gadget in this case?
-      // clang-format off
+    // clang-format off
       return stmt(arraySubscriptExpr(
             hasBase(ignoringParenImpCasts(
               anyOf(hasPointerType(), hasArrayType()))),
-            unless(hasIndex(
-                anyOf(integerLiteral(equals(0)), arrayInitIndexExpr())
-             )))
-            .bind(ArraySubscrTag));
+            unless(anyOf(
+              isSafeArraySubscript(),
+              hasIndex(
+                  anyOf(integerLiteral(equals(0)), arrayInitIndexExpr())
----------------
jkorous-apple wrote:

This is unnecessary now.

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


More information about the cfe-commits mailing list