Skip to content

Commit

Permalink
Use llvm::is_contained (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazutakahirata committed Oct 24, 2021
1 parent f5f5926 commit 7cc8fa2
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 44 deletions.
7 changes: 2 additions & 5 deletions clang/lib/AST/ASTImporter.cpp
Expand Up @@ -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);
}
}
}
Expand Down
9 changes: 3 additions & 6 deletions clang/lib/Analysis/ObjCNoReturn.cpp
Expand Up @@ -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;
Expand Down
12 changes: 2 additions & 10 deletions clang/lib/Driver/ToolChains/Cuda.cpp
Expand Up @@ -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())
Expand Down
5 changes: 2 additions & 3 deletions clang/lib/Lex/ModuleMap.cpp
Expand Up @@ -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);
Expand Down
7 changes: 1 addition & 6 deletions clang/lib/Sema/SemaChecking.cpp
Expand Up @@ -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,
Expand Down
9 changes: 1 addition & 8 deletions clang/lib/Sema/SemaOpenMP.cpp
Expand Up @@ -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);
Expand Down
7 changes: 1 addition & 6 deletions lldb/source/Breakpoint/BreakpointID.cpp
Expand Up @@ -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) {
Expand Down

0 comments on commit 7cc8fa2

Please sign in to comment.