[llvm-branch-commits] [clang] [BoundsSafety] Support the counted_by family on function parameters (PR #234941)

Dan Liew via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Oct 23 10:50:27 PDT 2026


================
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsanitize=array-bounds -emit-llvm -o - %s | FileCheck %s
+
+// CodeGen does not use a function parameter's count yet: unlike a field's
+// count, it bounds neither -fsanitize=array-bounds nor
+// __builtin_dynamic_object_size.
+
+#define __counted_by(f)  __attribute__((counted_by(f)))
+
+// CHECK-LABEL: define dso_local i32 @subscript(
+// CHECK-NOT:     __ubsan_handle_out_of_bounds
+// CHECK:         ret i32
+//
+// FIXME: Check the index against the count.
----------------
delcypher wrote:

Rather than a standalone FIXME could you file a github issue and refer to it here?

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


More information about the llvm-branch-commits mailing list