================ @@ -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()); + } ---------------- nickdesaulniers wrote:
That's ignoring a lot of casts! Could this perhaps be: ``` if (auto *ME = dyn_cast<MemberExpr>(Base)) Base = ME->getBase()->IgnoreImpCasts()->IgnoreParentNoopCasts(getContext); ``` The call to `IgnoreImpCasts` in the `if` seems handled before the loop, and in the loop body? https://github.com/llvm/llvm-project/pull/70606 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits