https://github.com/snarang181 updated 
https://github.com/llvm/llvm-project/pull/143275

>From c18c91f7f8f4332696dd309a5164c568f32c137b Mon Sep 17 00:00:00 2001
From: Samarth Narang <snar...@umass.edu>
Date: Sat, 7 Jun 2025 12:21:17 -0400
Subject: [PATCH 1/2] Replace loop with llvm:any_of

---
 clang/include/clang/AST/DeclContextInternals.h | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/clang/include/clang/AST/DeclContextInternals.h 
b/clang/include/clang/AST/DeclContextInternals.h
index b17b7627ac90c..a1071f62d5fae 100644
--- a/clang/include/clang/AST/DeclContextInternals.h
+++ b/clang/include/clang/AST/DeclContextInternals.h
@@ -176,14 +176,10 @@ class StoredDeclsList {
     DeclListNode::Decls *Tail = erase_if([Decls](NamedDecl *ND) {
       if (ND->isFromASTFile())
         return true;
-      // FIXME: Can we get rid of this loop completely?
-      for (NamedDecl *D : Decls)
-        // Only replace the local declaration if the external declaration has
-        // higher visibilities.
-        if (D->getModuleOwnershipKind() <= ND->getModuleOwnershipKind() &&
-            D->declarationReplaces(ND, /*IsKnownNewer=*/false))
-          return true;
-      return false;
+      return llvm::any_of(Decls, [ND](NamedDecl *D) {
+        return D->getModuleOwnershipKind() <= ND->getModuleOwnershipKind() &&
+               D->declarationReplaces(ND, /*IsKnownNewer=*/false);
+      });
     });
 
     // Don't have any pending external decls any more.

>From f8498219698ab33b512d82ac3fc9df5ab69f3b57 Mon Sep 17 00:00:00 2001
From: Samarth Narang <snar...@umass.edu>
Date: Sun, 8 Jun 2025 22:07:43 -0400
Subject: [PATCH 2/2] Retain comments

---
 clang/include/clang/AST/DeclContextInternals.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang/include/clang/AST/DeclContextInternals.h 
b/clang/include/clang/AST/DeclContextInternals.h
index a1071f62d5fae..a0f37886cc014 100644
--- a/clang/include/clang/AST/DeclContextInternals.h
+++ b/clang/include/clang/AST/DeclContextInternals.h
@@ -176,7 +176,10 @@ class StoredDeclsList {
     DeclListNode::Decls *Tail = erase_if([Decls](NamedDecl *ND) {
       if (ND->isFromASTFile())
         return true;
+      // FIXME: Can we get rid of this loop completely?
       return llvm::any_of(Decls, [ND](NamedDecl *D) {
+        // Only replace the local declaration if the external declaration has
+        // higher visiblities.
         return D->getModuleOwnershipKind() <= ND->getModuleOwnershipKind() &&
                D->declarationReplaces(ND, /*IsKnownNewer=*/false);
       });

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to