Author: Kazu Hirata Date: 2021-10-24T09:32:57-07:00 New Revision: 7cc8fa2dd2d8167d427cadb4fc6f4254b53a8359
URL: https://github.com/llvm/llvm-project/commit/7cc8fa2dd2d8167d427cadb4fc6f4254b53a8359 DIFF: https://github.com/llvm/llvm-project/commit/7cc8fa2dd2d8167d427cadb4fc6f4254b53a8359.diff LOG: Use llvm::is_contained (NFC) Added: Modified: clang/lib/AST/ASTImporter.cpp clang/lib/Analysis/ObjCNoReturn.cpp clang/lib/Driver/ToolChains/Cuda.cpp clang/lib/Lex/ModuleMap.cpp clang/lib/Sema/SemaChecking.cpp clang/lib/Sema/SemaOpenMP.cpp lldb/source/Breakpoint/BreakpointID.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index 1afc1e13d25a7..4e74355f2639a 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -300,11 +300,8 @@ namespace clang { auto *ToNamed = cast<NamedDecl>(ToD); DeclContextLookupResult FromLookup = FromDC->lookup(FromNamed->getDeclName()); - for (NamedDecl *ND : FromLookup) - if (ND == FromNamed) { - ToDC->makeDeclVisibleInContext(ToNamed); - break; - } + if (llvm::is_contained(FromLookup, FromNamed)) + ToDC->makeDeclVisibleInContext(ToNamed); } } } diff --git a/clang/lib/Analysis/ObjCNoReturn.cpp b/clang/lib/Analysis/ObjCNoReturn.cpp index fe1edb496859e..9d7c365c3b992 100644 --- a/clang/lib/Analysis/ObjCNoReturn.cpp +++ b/clang/lib/Analysis/ObjCNoReturn.cpp @@ -54,12 +54,9 @@ bool ObjCNoReturn::isImplicitNoReturn(const ObjCMessageExpr *ME) { } if (const ObjCInterfaceDecl *ID = ME->getReceiverInterface()) { - if (isSubclass(ID, NSExceptionII)) { - for (unsigned i = 0; i < NUM_RAISE_SELECTORS; ++i) { - if (S == NSExceptionInstanceRaiseSelectors[i]) - return true; - } - } + if (isSubclass(ID, NSExceptionII) && + llvm::is_contained(NSExceptionInstanceRaiseSelectors, S)) + return true; } return false; diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp b/clang/lib/Driver/ToolChains/Cuda.cpp index 0ad1ffb079b31..09418aa2390f2 100644 --- a/clang/lib/Driver/ToolChains/Cuda.cpp +++ b/clang/lib/Driver/ToolChains/Cuda.cpp @@ -822,17 +822,9 @@ CudaToolChain::TranslateArgs(const llvm::opt::DerivedArgList &Args, // flags are not duplicated. // Also append the compute capability. if (DeviceOffloadKind == Action::OFK_OpenMP) { - for (Arg *A : Args) { - bool IsDuplicate = false; - for (Arg *DALArg : *DAL) { - if (A == DALArg) { - IsDuplicate = true; - break; - } - } - if (!IsDuplicate) + for (Arg *A : Args) + if (!llvm::is_contained(*DAL, A)) DAL->append(A); - } StringRef Arch = DAL->getLastArgValue(options::OPT_march_EQ); if (Arch.empty()) diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp index 08381d0422058..6324cdc5a6b0a 100644 --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/lib/Lex/ModuleMap.cpp @@ -1217,9 +1217,8 @@ void ModuleMap::addHeader(Module *Mod, Module::Header Header, // FIXME: Should we diagnose if a header is listed twice in the // same module definition? auto &HeaderList = Headers[Header.Entry]; - for (auto H : HeaderList) - if (H == KH) - return; + if (llvm::is_contained(HeaderList, KH)) + return; HeaderList.push_back(KH); Mod->Headers[headerRoleToKind(Role)].push_back(Header); diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index a7a48016fe1e2..63c2d9fff8816 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -2688,12 +2688,7 @@ static bool isValidBPFPreserveEnumValueArg(Expr *Arg) { return false; // The enum value must be supported. - for (auto *EDI : ET->getDecl()->enumerators()) { - if (EDI == Enumerator) - return true; - } - - return false; + return llvm::is_contained(ET->getDecl()->enumerators(), Enumerator); } bool Sema::CheckBPFBuiltinFunctionCall(unsigned BuiltinID, diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 2e8f208866803..ccd17fc5102d1 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -4963,14 +4963,7 @@ static bool checkIfClauses(Sema &S, OpenMPDirectiveKind Kind, // directive. // At most one if clause with the particular directive-name-modifier can // appear on the directive. - bool MatchFound = false; - for (auto NM : AllowedNameModifiers) { - if (CurNM == NM) { - MatchFound = true; - break; - } - } - if (!MatchFound) { + if (!llvm::is_contained(AllowedNameModifiers, CurNM)) { S.Diag(IC->getNameModifierLoc(), diag::err_omp_wrong_if_directive_name_modifier) << getOpenMPDirectiveName(CurNM) << getOpenMPDirectiveName(Kind); diff --git a/lldb/source/Breakpoint/BreakpointID.cpp b/lldb/source/Breakpoint/BreakpointID.cpp index f205721440687..9bd22898196e4 100644 --- a/lldb/source/Breakpoint/BreakpointID.cpp +++ b/lldb/source/Breakpoint/BreakpointID.cpp @@ -29,12 +29,7 @@ static llvm::StringRef g_range_specifiers[] = {"-", "to", "To", "TO"}; // for specifying ID ranges at a later date. bool BreakpointID::IsRangeIdentifier(llvm::StringRef str) { - for (auto spec : g_range_specifiers) { - if (spec == str) - return true; - } - - return false; + return llvm::is_contained(g_range_specifiers, str); } bool BreakpointID::IsValidIDExpression(llvm::StringRef str) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits