[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

Bill Wendling via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 7 14:55:36 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:

There's a key difference. Emitting the code to access "array" is potentially far more complex than the code to access "count". This is because "count" will be either at the top level of the structure or in an anonymous structure at the top level. The GEP indices are therefore much simpler to calculate.

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


More information about the cfe-commits mailing list