Skip to content

Commit 7cc8fa2

Browse files
Use llvm::is_contained (NFC)
1 parent f5f5926 commit 7cc8fa2

File tree

7 files changed

+12
-44
lines changed

7 files changed

+12
-44
lines changed

clang/lib/AST/ASTImporter.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,8 @@ namespace clang {
300300
auto *ToNamed = cast<NamedDecl>(ToD);
301301
DeclContextLookupResult FromLookup =
302302
FromDC->lookup(FromNamed->getDeclName());
303-
for (NamedDecl *ND : FromLookup)
304-
if (ND == FromNamed) {
305-
ToDC->makeDeclVisibleInContext(ToNamed);
306-
break;
307-
}
303+
if (llvm::is_contained(FromLookup, FromNamed))
304+
ToDC->makeDeclVisibleInContext(ToNamed);
308305
}
309306
}
310307
}

clang/lib/Analysis/ObjCNoReturn.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,9 @@ bool ObjCNoReturn::isImplicitNoReturn(const ObjCMessageExpr *ME) {
5454
}
5555

5656
if (const ObjCInterfaceDecl *ID = ME->getReceiverInterface()) {
57-
if (isSubclass(ID, NSExceptionII)) {
58-
for (unsigned i = 0; i < NUM_RAISE_SELECTORS; ++i) {
59-
if (S == NSExceptionInstanceRaiseSelectors[i])
60-
return true;
61-
}
62-
}
57+
if (isSubclass(ID, NSExceptionII) &&
58+
llvm::is_contained(NSExceptionInstanceRaiseSelectors, S))
59+
return true;
6360
}
6461

6562
return false;

clang/lib/Driver/ToolChains/Cuda.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -822,17 +822,9 @@ CudaToolChain::TranslateArgs(const llvm::opt::DerivedArgList &Args,
822822
// flags are not duplicated.
823823
// Also append the compute capability.
824824
if (DeviceOffloadKind == Action::OFK_OpenMP) {
825-
for (Arg *A : Args) {
826-
bool IsDuplicate = false;
827-
for (Arg *DALArg : *DAL) {
828-
if (A == DALArg) {
829-
IsDuplicate = true;
830-
break;
831-
}
832-
}
833-
if (!IsDuplicate)
825+
for (Arg *A : Args)
826+
if (!llvm::is_contained(*DAL, A))
834827
DAL->append(A);
835-
}
836828

837829
StringRef Arch = DAL->getLastArgValue(options::OPT_march_EQ);
838830
if (Arch.empty())

clang/lib/Lex/ModuleMap.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,9 +1217,8 @@ void ModuleMap::addHeader(Module *Mod, Module::Header Header,
12171217
// FIXME: Should we diagnose if a header is listed twice in the
12181218
// same module definition?
12191219
auto &HeaderList = Headers[Header.Entry];
1220-
for (auto H : HeaderList)
1221-
if (H == KH)
1222-
return;
1220+
if (llvm::is_contained(HeaderList, KH))
1221+
return;
12231222

12241223
HeaderList.push_back(KH);
12251224
Mod->Headers[headerRoleToKind(Role)].push_back(Header);

clang/lib/Sema/SemaChecking.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2688,12 +2688,7 @@ static bool isValidBPFPreserveEnumValueArg(Expr *Arg) {
26882688
return false;
26892689

26902690
// The enum value must be supported.
2691-
for (auto *EDI : ET->getDecl()->enumerators()) {
2692-
if (EDI == Enumerator)
2693-
return true;
2694-
}
2695-
2696-
return false;
2691+
return llvm::is_contained(ET->getDecl()->enumerators(), Enumerator);
26972692
}
26982693

26992694
bool Sema::CheckBPFBuiltinFunctionCall(unsigned BuiltinID,

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4963,14 +4963,7 @@ static bool checkIfClauses(Sema &S, OpenMPDirectiveKind Kind,
49634963
// directive.
49644964
// At most one if clause with the particular directive-name-modifier can
49654965
// appear on the directive.
4966-
bool MatchFound = false;
4967-
for (auto NM : AllowedNameModifiers) {
4968-
if (CurNM == NM) {
4969-
MatchFound = true;
4970-
break;
4971-
}
4972-
}
4973-
if (!MatchFound) {
4966+
if (!llvm::is_contained(AllowedNameModifiers, CurNM)) {
49744967
S.Diag(IC->getNameModifierLoc(),
49754968
diag::err_omp_wrong_if_directive_name_modifier)
49764969
<< getOpenMPDirectiveName(CurNM) << getOpenMPDirectiveName(Kind);

lldb/source/Breakpoint/BreakpointID.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,7 @@ static llvm::StringRef g_range_specifiers[] = {"-", "to", "To", "TO"};
2929
// for specifying ID ranges at a later date.
3030

3131
bool BreakpointID::IsRangeIdentifier(llvm::StringRef str) {
32-
for (auto spec : g_range_specifiers) {
33-
if (spec == str)
34-
return true;
35-
}
36-
37-
return false;
32+
return llvm::is_contained(g_range_specifiers, str);
3833
}
3934

4035
bool BreakpointID::IsValidIDExpression(llvm::StringRef str) {

0 commit comments

Comments
 (0)