[clang] [Clang] Implement the 'counted_by' attribute (PR #76348)

Yeoul Na via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 8 11:42:50 PST 2024


================
@@ -1155,15 +1159,14 @@ const FieldDecl *CodeGenFunction::FindCountedByField(const FieldDecl *FD) {
     return nullptr;
 
   auto GetNonAnonStructOrUnion = [](const RecordDecl *RD) {
-    while (RD && !RD->getDeclName())
-      if (const auto *R = dyn_cast<RecordDecl>(RD->getDeclContext()))
-        RD = R;
-      else
+    while (RD && RD->isAnonymousStructOrUnion()) {
+      const auto *R = dyn_cast<RecordDecl>(RD->getDeclContext());
+      if (!R)
----------------
rapidsna wrote:

Can `!R` condition be actually reachable? IOW, can an anonymous struct or union has a parent that is not a RecordDecl?

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


More information about the cfe-commits mailing list