[clang] [CodeGen] Revamp counted_by calculations (PR #70606)
Bill Wendling via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 30 15:00:26 PDT 2023
================
@@ -966,9 +962,68 @@ static llvm::Value *getArrayIndexingBound(CodeGenFunction &CGF,
return nullptr;
}
-FieldDecl *CodeGenFunction::FindCountedByField(
- const Expr *Base,
- LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel) {
+Expr *CodeGenFunction::BuildCountedByFieldExpr(Expr *Base,
+ const ValueDecl *CountedByVD) {
+ // Find the outer struct expr (i.e. p in p->a.b.c.d).
+ Base = Base->IgnoreImpCasts();
+ Base = Base->IgnoreParenNoopCasts(getContext());
+
+ // Work our way up the expression until we reach the DeclRefExpr.
+ while (!isa<DeclRefExpr>(Base))
+ if (auto *ME = dyn_cast<MemberExpr>(Base->IgnoreImpCasts())) {
+ Base = ME->getBase()->IgnoreImpCasts();
+ Base = Base->IgnoreParenNoopCasts(getContext());
+ }
----------------
bwendling wrote:
Not sure why this didn't add my comment. Anyway, I changed it to use `IgnoreParenImpCasts` like in the other code.
https://github.com/llvm/llvm-project/pull/70606
More information about the cfe-commits
mailing list