[clang-tools-extra] 840a968 - [clang-tools-extra] Use range-based for loops (NFC)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Sat Sep 2 12:12:26 PDT 2023
Author: Kazu Hirata
Date: 2023-09-02T12:12:16-07:00
New Revision: 840a968226c2c6db792d7c1661dfb8a354ff3ebf
URL: https://github.com/llvm/llvm-project/commit/840a968226c2c6db792d7c1661dfb8a354ff3ebf
DIFF: https://github.com/llvm/llvm-project/commit/840a968226c2c6db792d7c1661dfb8a354ff3ebf.diff
LOG: [clang-tools-extra] Use range-based for loops (NFC)
Added:
Modified:
clang-tools-extra/clangd/CompileCommands.cpp
clang-tools-extra/clangd/ParsedAST.cpp
clang-tools-extra/clangd/Preamble.cpp
clang-tools-extra/include-cleaner/lib/WalkAST.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/CompileCommands.cpp b/clang-tools-extra/clangd/CompileCommands.cpp
index ef5d5db0577b0d..e116a739774b85 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -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("--");
diff --git a/clang-tools-extra/clangd/ParsedAST.cpp b/clang-tools-extra/clangd/ParsedAST.cpp
index 3cf6671be9600e..3e06a67566cf75 100644
--- a/clang-tools-extra/clangd/ParsedAST.cpp
+++ b/clang-tools-extra/clangd/ParsedAST.cpp
@@ -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;
diff --git a/clang-tools-extra/clangd/Preamble.cpp b/clang-tools-extra/clangd/Preamble.cpp
index 31b38d067b2727..725e6b1e34fea3 100644
--- a/clang-tools-extra/clangd/Preamble.cpp
+++ b/clang-tools-extra/clangd/Preamble.cpp
@@ -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(),
diff --git a/clang-tools-extra/include-cleaner/lib/WalkAST.cpp b/clang-tools-extra/include-cleaner/lib/WalkAST.cpp
index 15a579afd456c3..796a645ec29466 100644
--- a/clang-tools-extra/include-cleaner/lib/WalkAST.cpp
+++ b/clang-tools-extra/include-cleaner/lib/WalkAST.cpp
@@ -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;
}
More information about the cfe-commits
mailing list