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

John McCall via libc-commits libc-commits at lists.llvm.org
Mon Dec 18 14:24:53 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();
+  }
----------------
rjmccall wrote:

It's computing and casting things once instead of twice.  It's just generally much clearer.

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


More information about the libc-commits mailing list