Skip to content

Commit

Permalink
[clang-tools-extra] Use range-based for loops (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazutakahirata committed Sep 2, 2023
1 parent 384b815 commit 840a968
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
8 changes: 4 additions & 4 deletions clang-tools-extra/clangd/CompileCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,10 @@ void CommandMangler::operator()(tooling::CompileCommand &Command,
Cmd.resize(DashDashIndex);
}
llvm::sort(IndicesToDrop);
llvm::for_each(llvm::reverse(IndicesToDrop),
// +1 to account for the executable name in Cmd[0] that
// doesn't exist in ArgList.
[&Cmd](unsigned Idx) { Cmd.erase(Cmd.begin() + Idx + 1); });
for (unsigned Idx : llvm::reverse(IndicesToDrop))
// +1 to account for the executable name in Cmd[0] that
// doesn't exist in ArgList.
Cmd.erase(Cmd.begin() + Idx + 1);
// All the inputs are stripped, append the name for the requested file. Rest
// of the modifications should respect `--`.
Cmd.push_back("--");
Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clangd/ParsedAST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
StoreDiags ASTDiags;
ASTDiags.setDiagCallback(
[&ASTListeners](const clang::Diagnostic &D, clangd::Diag &Diag) {
llvm::for_each(ASTListeners,
[&](const auto &L) { L->sawDiagnostic(D, Diag); });
for (const auto &L : ASTListeners)
L->sawDiagnostic(D, Diag);
});

std::optional<PreamblePatch> Patch;
Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clangd/Preamble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,8 +610,8 @@ buildPreamble(PathRef FileName, CompilerInvocation CI,
StoreDiags PreambleDiagnostics;
PreambleDiagnostics.setDiagCallback(
[&ASTListeners](const clang::Diagnostic &D, clangd::Diag &Diag) {
llvm::for_each(ASTListeners,
[&](const auto &L) { L->sawDiagnostic(D, Diag); });
for (const auto &L : ASTListeners)
L->sawDiagnostic(D, Diag);
});
llvm::IntrusiveRefCntPtr<DiagnosticsEngine> PreambleDiagsEngine =
CompilerInstance::createDiagnostics(&CI.getDiagnosticOpts(),
Expand Down
3 changes: 1 addition & 2 deletions clang-tools-extra/include-cleaner/lib/WalkAST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,8 @@ class ASTWalker : public RecursiveASTVisitor<ASTWalker> {

bool VisitOverloadExpr(OverloadExpr *E) {
// Since we can't prove which overloads are used, report all of them.
llvm::for_each(E->decls(), [this, E](NamedDecl *D) {
for (NamedDecl *D : E->decls())
report(E->getNameLoc(), D, RefType::Ambiguous);
});
return true;
}

Expand Down

0 comments on commit 840a968

Please sign in to comment.