Skip to content

Commit

Permalink
[clang] Use llvm::is_contained (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazutakahirata committed Oct 15, 2021
1 parent 59b94c4 commit 6a154e6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 31 deletions.
6 changes: 1 addition & 5 deletions clang/include/clang/ASTMatchers/ASTMatchersInternal.h
Expand Up @@ -2249,11 +2249,7 @@ class HasAnyOperatorNameMatcher : public SingleNodeMatcherInterface<T> {

bool matchesNode(const T &Node) const override {
Optional<StringRef> OptOpName = getOpName(Node);
if (!OptOpName)
return false;
return llvm::any_of(Names, [OpName = *OptOpName](const std::string &Name) {
return Name == OpName;
});
return OptOpName && llvm::is_contained(Names, *OptOpName);
}

private:
Expand Down
29 changes: 9 additions & 20 deletions clang/lib/CodeGen/CGOpenMPRuntime.cpp
Expand Up @@ -8580,10 +8580,8 @@ class MappableExprsHandler {
if (!C)
continue;
MapKind Kind = Other;
if (!C->getMapTypeModifiers().empty() &&
llvm::any_of(C->getMapTypeModifiers(), [](OpenMPMapModifierKind K) {
return K == OMPC_MAP_MODIFIER_present;
}))
if (llvm::is_contained(C->getMapTypeModifiers(),
OMPC_MAP_MODIFIER_present))
Kind = Present;
else if (C->getMapType() == OMPC_MAP_alloc)
Kind = Allocs;
Expand All @@ -8602,10 +8600,8 @@ class MappableExprsHandler {
if (!C)
continue;
MapKind Kind = Other;
if (!C->getMotionModifiers().empty() &&
llvm::any_of(C->getMotionModifiers(), [](OpenMPMotionModifierKind K) {
return K == OMPC_MOTION_MODIFIER_present;
}))
if (llvm::is_contained(C->getMotionModifiers(),
OMPC_MOTION_MODIFIER_present))
Kind = Present;
const auto *EI = C->getVarRefs().begin();
for (const auto L : C->component_lists()) {
Expand All @@ -8620,10 +8616,8 @@ class MappableExprsHandler {
if (!C)
continue;
MapKind Kind = Other;
if (!C->getMotionModifiers().empty() &&
llvm::any_of(C->getMotionModifiers(), [](OpenMPMotionModifierKind K) {
return K == OMPC_MOTION_MODIFIER_present;
}))
if (llvm::is_contained(C->getMotionModifiers(),
OMPC_MOTION_MODIFIER_present))
Kind = Present;
const auto *EI = C->getVarRefs().begin();
for (const auto L : C->component_lists()) {
Expand Down Expand Up @@ -9191,18 +9185,13 @@ class MappableExprsHandler {
const MapData &RHS) {
ArrayRef<OpenMPMapModifierKind> MapModifiers = std::get<2>(LHS);
OpenMPMapClauseKind MapType = std::get<1>(RHS);
bool HasPresent = !MapModifiers.empty() &&
llvm::any_of(MapModifiers, [](OpenMPMapModifierKind K) {
return K == clang::OMPC_MAP_MODIFIER_present;
});
bool HasPresent =
llvm::is_contained(MapModifiers, clang::OMPC_MAP_MODIFIER_present);
bool HasAllocs = MapType == OMPC_MAP_alloc;
MapModifiers = std::get<2>(RHS);
MapType = std::get<1>(LHS);
bool HasPresentR =
!MapModifiers.empty() &&
llvm::any_of(MapModifiers, [](OpenMPMapModifierKind K) {
return K == clang::OMPC_MAP_MODIFIER_present;
});
llvm::is_contained(MapModifiers, clang::OMPC_MAP_MODIFIER_present);
bool HasAllocsR = MapType == OMPC_MAP_alloc;
return (HasPresent && !HasPresentR) || (HasAllocs && !HasAllocsR);
});
Expand Down
8 changes: 2 additions & 6 deletions clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
Expand Up @@ -102,12 +102,8 @@ static bool hasStdClassWithName(const CXXRecordDecl *RD,
ArrayRef<llvm::StringLiteral> Names) {
if (!RD || !RD->getDeclContext()->isStdNamespace())
return false;
if (RD->getDeclName().isIdentifier()) {
StringRef Name = RD->getName();
return llvm::any_of(Names, [&Name](StringRef GivenName) -> bool {
return Name == GivenName;
});
}
if (RD->getDeclName().isIdentifier())
return llvm::is_contained(Names, RD->getName());
return false;
}

Expand Down

0 comments on commit 6a154e6

Please sign in to comment.