[libc-commits] [llvm] [libc] [libcxx] [flang] [clang] [compiler-rt] [clang-tools-extra] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

Yeoul Na via libc-commits libc-commits at lists.llvm.org
Tue Dec 12 01:04:23 PST 2023


================
@@ -876,31 +876,26 @@ CodeGenFunction::emitFlexibleArrayMemberSize(const Expr *E, unsigned Type,
   }
 
   // Get the flexible array member Decl.
-  const ValueDecl *FAMDecl = nullptr;
+  const RecordDecl *OuterRD = nullptr;
   if (const auto *ME = dyn_cast<MemberExpr>(Base)) {
     // Check if \p Base is referencing the FAM itself.
-    if (const ValueDecl *MD = ME->getMemberDecl()) {
-      const LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel =
-          getLangOpts().getStrictFlexArraysLevel();
-      if (!Decl::isFlexibleArrayMemberLike(
-              Ctx, MD, MD->getType(), StrictFlexArraysLevel,
-              /*IgnoreTemplateOrMacroSubstitution=*/true))
-        return nullptr;
-
-      FAMDecl = MD;
-    }
+    if (const ValueDecl *VD = dyn_cast<FieldDecl>(ME->getMemberDecl()))
----------------
rapidsna wrote:

Did you mean `if (const FieldDecl *VD = dyn_cast<FieldDecl>(ME->getMemberDecl()))`? Or is there a reason you do `dyn_cast<FieldDecl>` and then assign it back to `ValueDecl *`?

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


More information about the libc-commits mailing list