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

Bill Wendling via flang-commits flang-commits at lists.llvm.org
Mon Nov 27 11:17:41 PST 2023


================
@@ -956,37 +956,55 @@ static llvm::Value *getArrayIndexingBound(CodeGenFunction &CGF,
   return nullptr;
 }
 
-const Expr *
-CodeGenFunction::BuildCountedByFieldExpr(const Expr *Base,
-                                         const ValueDecl *CountedByVD) {
+Expr *CodeGenFunction::BuildCountedByFieldExpr(const Expr *Base,
+                                               const ValueDecl *CountedByVD) {
   // Find the outer struct expr (i.e. p in p->a.b.c.d).
   Expr *CountedByExpr = const_cast<Expr *>(Base)->IgnoreParenImpCasts();
 
+  // Get the enclosing struct, but not the outermost enclosing struct.
+  const DeclContext *DC = CountedByVD->getLexicalDeclContext();
+  const RecordDecl *CountedByRD = dyn_cast<RecordDecl>(DC);
----------------
bwendling wrote:

Done.

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


More information about the flang-commits mailing list