Skip to content

[clang] Use range-based for loops (NFC) #146811

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions clang/include/clang/Sema/DeclSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -1821,8 +1821,8 @@ class DecompositionDeclarator {
if (DeleteBindings)
delete[] Bindings;
else
llvm::for_each(llvm::MutableArrayRef(Bindings, NumBindings),
[](Binding &B) { B.Attrs.reset(); });
for (Binding &B : llvm::MutableArrayRef(Bindings, NumBindings))
B.Attrs.reset();
Bindings = nullptr;
NumBindings = 0;
DeleteBindings = false;
Expand Down
15 changes: 5 additions & 10 deletions clang/lib/CIR/CodeGen/CIRGenOpenACCClause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,8 @@ class OpenACCClauseCIREmitter final
void setLastDeviceTypeClause(const OpenACCDeviceTypeClause &clause) {
lastDeviceTypeValues.clear();

llvm::for_each(clause.getArchitectures(),
[this](const DeviceTypeArgument &arg) {
lastDeviceTypeValues.push_back(
decodeDeviceType(arg.getIdentifierInfo()));
});
for (const DeviceTypeArgument &arg : clause.getArchitectures())
lastDeviceTypeValues.push_back(decodeDeviceType(arg.getIdentifierInfo()));
}

mlir::Value emitIntExpr(const Expr *intExpr) {
Expand Down Expand Up @@ -511,11 +508,9 @@ class OpenACCClauseCIREmitter final

if constexpr (isOneOfTypes<OpTy, mlir::acc::InitOp,
mlir::acc::ShutdownOp>) {
llvm::for_each(
clause.getArchitectures(), [this](const DeviceTypeArgument &arg) {
operation.addDeviceType(builder.getContext(),
decodeDeviceType(arg.getIdentifierInfo()));
});
for (const DeviceTypeArgument &arg : clause.getArchitectures())
operation.addDeviceType(builder.getContext(),
decodeDeviceType(arg.getIdentifierInfo()));
} else if constexpr (isOneOfTypes<OpTy, mlir::acc::SetOp>) {
assert(!operation.getDeviceTypeAttr() && "already have device-type?");
assert(clause.getArchitectures().size() <= 1);
Expand Down
8 changes: 3 additions & 5 deletions clang/lib/Driver/ToolChains/HIPSPV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,9 @@ void HIPSPVToolChain::addClangTargetOptions(
CC1Args.append(
{"-fvisibility=hidden", "-fapply-global-visibility-to-externs"});

llvm::for_each(getDeviceLibs(DriverArgs),
[&](const BitCodeLibraryInfo &BCFile) {
CC1Args.append({"-mlink-builtin-bitcode",
DriverArgs.MakeArgString(BCFile.Path)});
});
for (const BitCodeLibraryInfo &BCFile : getDeviceLibs(DriverArgs))
CC1Args.append(
{"-mlink-builtin-bitcode", DriverArgs.MakeArgString(BCFile.Path)});
}

Tool *HIPSPVToolChain::buildLinker() const {
Expand Down
4 changes: 2 additions & 2 deletions clang/tools/clang-installapi/ClangInstallAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ static bool run(ArrayRef<const char *> Args, const char *ProgName) {

if (!Opts.DriverOpts.DylibToVerify.empty()) {
TargetList Targets;
llvm::for_each(Opts.DriverOpts.Targets,
[&](const auto &T) { Targets.push_back(T.first); });
for (const auto &T : Opts.DriverOpts.Targets)
Targets.push_back(T.first);
if (!Ctx.Verifier->verifyBinaryAttrs(Targets, Ctx.BA, Ctx.Reexports,
Opts.LinkerOpts.AllowableClients,
Opts.LinkerOpts.RPaths, Ctx.FT))
Expand Down
12 changes: 6 additions & 6 deletions clang/tools/clang-installapi/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ getArgListFromJSON(const StringRef Input, llvm::opt::OptTable *Table,
}

std::vector<const char *> CArgs(Storage.size());
llvm::for_each(Storage,
[&CArgs](StringRef Str) { CArgs.emplace_back(Str.data()); });
for (StringRef Str : Storage)
CArgs.emplace_back(Str.data());

unsigned MissingArgIndex, MissingArgCount;
return Table->ParseArgs(CArgs, MissingArgIndex, MissingArgCount);
Expand Down Expand Up @@ -730,8 +730,8 @@ Options::Options(DiagnosticsEngine &Diag, FileManager *FM,
// After all InstallAPI necessary arguments have been collected. Go back and
// assign values that were unknown before the clang driver opt table was used.
ArchitectureSet AllArchs;
llvm::for_each(DriverOpts.Targets,
[&AllArchs](const auto &T) { AllArchs.set(T.first.Arch); });
for (const auto &T : DriverOpts.Targets)
AllArchs.set(T.first.Arch);
auto assignDefaultLibAttrs = [&AllArchs](LibAttrs &Attrs) {
for (auto &[_, Archs] : Attrs.get())
if (Archs.empty())
Expand Down Expand Up @@ -794,8 +794,8 @@ std::pair<LibAttrs, ReexportedInterfaces> Options::getReexportedLibraries() {
};

PlatformSet Platforms;
llvm::for_each(DriverOpts.Targets,
[&](const auto &T) { Platforms.insert(T.first.Platform); });
for (const auto &T : DriverOpts.Targets)
Platforms.insert(T.first.Platform);
// Populate search paths by looking at user paths before system ones.
PathSeq FwkSearchPaths(FEOpts.FwkPaths.begin(), FEOpts.FwkPaths.end());
for (const PlatformType P : Platforms) {
Expand Down
Loading