[libc-commits] [clang-tools-extra] [flang] [compiler-rt] [clang] [llvm] [libc] [libcxx] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

Bill Wendling via libc-commits libc-commits at lists.llvm.org
Fri Dec 15 13:00:54 PST 2023


================
@@ -4022,8 +4169,36 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E,
       ArrayLV = EmitArraySubscriptExpr(ASE, /*Accessed*/ true);
     else
       ArrayLV = EmitLValue(Array);
+
     auto *Idx = EmitIdxAfterBase(/*Promote*/true);
 
+    if (SanOpts.has(SanitizerKind::ArrayBounds)) {
----------------
bwendling wrote:

No. there are only two places where we look at the `__counted_by` attribute: during bounds checking, and in a `__builtin_dynamic_object_size` statement. The former is the main focus of this patch. The latter attempts to calculate the size without introducing side-effects from the loading `count`. They both use similar paths, though I've been toying with your idea of using the offsets and it seems to work and may be more robust than trying to build the array and count accesses off of the same base pointer.

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


More information about the libc-commits mailing list