[libcxx] [flang] [clang] [llvm] [compiler-rt] [libc] [Clang] Use correct base expression for counted_by field (#73168) (PR #73465)

Bill Wendling via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 27 11:54:15 PST 2023


================
@@ -916,7 +916,7 @@ CodeGenFunction::emitFlexibleArrayMemberSize(const Expr *E, unsigned Type,
 
   // Build a load of the counted_by field.
   bool IsSigned = CountedByFD->getType()->isSignedIntegerType();
-  const Expr *CountedByExpr = BuildCountedByFieldExpr(Base, CountedByFD);
+  Expr *CountedByExpr = BuildCountedByFieldExpr(Base, CountedByFD);
----------------
bwendling wrote:

Sure, that would be fine. However, dealing with all of the forms that the expression can take is a nightmare that the `::Emit*Expr` all ready deal with. I don't think it's as simple as "find the GEP of the FAM and then replace the indices with that of the `counted_by` field."

Or perhaps I'm wrong? @AaronBallman You'd know more about it than I would. Are the `::Emit*Expr` methods going to generate more than a load and GEP for this?

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


More information about the cfe-commits mailing list