[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 12:22:50 PST 2023
================
@@ -4022,8 +4168,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)) {
+ const LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel =
+ getLangOpts().getStrictFlexArraysLevel();
+
+ if (const auto *ME = dyn_cast<MemberExpr>(Array);
+ ME &&
+ ME->isFlexibleArrayMemberLike(getContext(), StrictFlexArraysLevel) &&
+ ME->getMemberDecl()->hasAttr<CountedByAttr>()) {
+ RecordDecl *RD = ME->getMemberDecl()
+ ->getDeclContext()
+ ->getOuterLexicalRecordContext();
+ Expr *StructBase =
+ StructAccessBase(RD).Visit(const_cast<MemberExpr *>(ME));
+
+ if (StructBase && StructBase->getType()->isPointerType()) {
----------------
bwendling wrote:
Done.
https://github.com/llvm/llvm-project/pull/73730
More information about the cfe-commits
mailing list