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

Bill Wendling via libc-commits libc-commits at lists.llvm.org
Mon Dec 18 14:07:46 PST 2023


================
@@ -8522,6 +8522,22 @@ bool Sema::CheckCountedByAttr(Scope *S, const FieldDecl *FD) {
     }
   }
 
+  // We don't support 'counted_by' on flexible array members in substructures.
+  const DeclContext *DC = FD->getParent();
+  while (const auto *RD = dyn_cast<RecordDecl>(DC)) {
+    if (!RD->isAnonymousStructOrUnion() ||
+        !isa<RecordDecl>(RD->getLexicalParent()))
+      break;
+    DC = RD->getLexicalParent();
+  }
+
+  if (DC != FD->getDeclContext()->getOuterLexicalRecordContext()) {
----------------
bwendling wrote:

I added this to ensure that we're not dealing with FAMs in sub-structures. I need to work with @rapidsna's work to make sure that what they do is what this attribute will do. It's not really a perfect check, but I removed the code in CodeGen that handles FAMs in substructs. So I think we can table this discussion if this patch goes on.

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


More information about the libc-commits mailing list