From: Kazu Hirata Date: Fri, 15 Oct 2021 17:07:08 +0000 (-0700) Subject: [clang] Use llvm::is_contained (NFC) X-Git-Tag: upstream/15.0.7~28499 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6a154e606e570870789b047a10c21642dce2fdd3;p=platform%2Fupstream%2Fllvm.git [clang] Use llvm::is_contained (NFC) --- diff --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h index 488f9d8..1a4137c 100644 --- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h +++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h @@ -2249,11 +2249,7 @@ public: bool matchesNode(const T &Node) const override { Optional 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: diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index ce92627..399bfdb 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -8580,10 +8580,8 @@ private: 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; @@ -8602,10 +8600,8 @@ private: 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()) { @@ -8620,10 +8616,8 @@ private: 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()) { @@ -9191,18 +9185,13 @@ public: const MapData &RHS) { ArrayRef 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); }); diff --git a/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp b/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp index 09e885e..190bb4c 100644 --- a/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp @@ -102,12 +102,8 @@ static bool hasStdClassWithName(const CXXRecordDecl *RD, ArrayRef 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; }