Author: Samarth Narang
Date: 2025-06-10T10:22:23+08:00
New Revision: ab954b11dbf7c5f0256b5a93b6c221b6e82a4f28

URL: 
https://github.com/llvm/llvm-project/commit/ab954b11dbf7c5f0256b5a93b6c221b6e82a4f28
DIFF: 
https://github.com/llvm/llvm-project/commit/ab954b11dbf7c5f0256b5a93b6c221b6e82a4f28.diff

LOG: [clang][NFC] Refactor replaceExternalDecls to use llvm::any_of (#143275)

This patch simplifies the declaration replacement logic in
replaceExternalDecls by replacing a manual loop with an idiomatic use of
llvm::any_of. This improves code readability and aligns with common LLVM
coding style.

Added: 
    

Modified: 
    clang/include/clang/AST/DeclContextInternals.h

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/AST/DeclContextInternals.h 
b/clang/include/clang/AST/DeclContextInternals.h
index b17b7627ac90c..a0f37886cc014 100644
--- a/clang/include/clang/AST/DeclContextInternals.h
+++ b/clang/include/clang/AST/DeclContextInternals.h
@@ -177,13 +177,12 @@ class StoredDeclsList {
       if (ND->isFromASTFile())
         return true;
       // FIXME: Can we get rid of this loop completely?
-      for (NamedDecl *D : Decls)
+      return llvm::any_of(Decls, [ND](NamedDecl *D) {
         // 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;
+        // higher visiblities.
+        return D->getModuleOwnershipKind() <= ND->getModuleOwnershipKind() &&
+               D->declarationReplaces(ND, /*IsKnownNewer=*/false);
+      });
     });
 
     // Don't have any pending external decls any more.


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

Reply via email to