Skip to content

Commit ab954b1

Browse files
authored
[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.
1 parent 505c550 commit ab954b1

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

clang/include/clang/AST/DeclContextInternals.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,12 @@ class StoredDeclsList {
177177
if (ND->isFromASTFile())
178178
return true;
179179
// FIXME: Can we get rid of this loop completely?
180-
for (NamedDecl *D : Decls)
180+
return llvm::any_of(Decls, [ND](NamedDecl *D) {
181181
// Only replace the local declaration if the external declaration has
182-
// higher visibilities.
183-
if (D->getModuleOwnershipKind() <= ND->getModuleOwnershipKind() &&
184-
D->declarationReplaces(ND, /*IsKnownNewer=*/false))
185-
return true;
186-
return false;
182+
// higher visiblities.
183+
return D->getModuleOwnershipKind() <= ND->getModuleOwnershipKind() &&
184+
D->declarationReplaces(ND, /*IsKnownNewer=*/false);
185+
});
187186
});
188187

189188
// Don't have any pending external decls any more.

0 commit comments

Comments
 (0)