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

John McCall via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 15 13:25:23 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)) {
----------------
rjmccall wrote:

Okay, I think I'm starting to see the root of my confusion here.  It looks like you *are* updating the common infrastructure for computing bounds. You are *also* adding a new bounds check for array subscripts into flexible array members, and that code seems to be quite a bit more complex than just calling into the common infrastructure.

@rapidsna Is there a specification for bound expressions?  I would like to understand how this works a little better, and in particular I am concerned about the idea that bound expressions can involve a path that isn't rooted in the same struct as the bounded member.

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


More information about the cfe-commits mailing list