Skip to content

Commit

Permalink
[clang-tidy][task 46] enable modernize-avoid-bind (#55895)
Browse files Browse the repository at this point in the history
* [clang-tidy] modernize-avoid-bind

* rollback
  • Loading branch information
gouzil authored Aug 3, 2023
1 parent 8444549 commit a172e6c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ bugprone-unused-raii,
-hicpp-exception-baseclass,
-misc-unused-alias-decls,
-misc-unused-using-decls,
-modernize-avoid-bind,
modernize-avoid-bind,
-modernize-avoid-c-arrays,
-modernize-deprecated-headers,
-modernize-deprecated-ios-base-aliases,
Expand Down
3 changes: 1 addition & 2 deletions paddle/fluid/framework/dist_multi_trainer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ void DistMultiTrainer::InitDumpEnv() {
}
}
for (int i = 0; i < dump_thread_num_; i++) {
dump_thread_.push_back(
std::thread(std::bind(&TrainerBase::DumpWork, this, i)));
dump_thread_.push_back(std::thread([this, i] { DumpWork(i); }));
}
}

Expand Down
3 changes: 1 addition & 2 deletions paddle/fluid/framework/multi_trainer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ void MultiTrainer::InitDumpEnv() {
}
}
for (int i = 0; i < dump_thread_num_; i++) {
dump_thread_.push_back(
std::thread(std::bind(&TrainerBase::DumpWork, this, i)));
dump_thread_.push_back(std::thread([this, i] { DumpWork(i); }));
}
}

Expand Down
7 changes: 4 additions & 3 deletions paddle/fluid/framework/op_desc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,10 @@ class CompileTimeInferShapeContext : public InferShapeContext {
names.begin(),
names.end(),
retv.begin(),
std::bind(std::mem_fn(&CompileTimeInferShapeContext::GetVarType),
this,
std::placeholders::_1));
std::bind(
std::mem_fn(&CompileTimeInferShapeContext::GetVarType), // NOLINT
this,
std::placeholders::_1));
return retv;
}

Expand Down
13 changes: 7 additions & 6 deletions paddle/fluid/framework/operator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -710,12 +710,13 @@ std::vector<proto::VarType::Type> RuntimeInferShapeContext::GetVarTypes(
const std::vector<Variable*>& vars) const {
std::vector<proto::VarType::Type> retv;
retv.resize(vars.size());
std::transform(vars.begin(),
vars.end(),
retv.begin(),
std::bind(std::mem_fn(&RuntimeInferShapeContext::GetVarType),
this,
std::placeholders::_1));
std::transform(
vars.begin(),
vars.end(),
retv.begin(),
std::bind(std::mem_fn(&RuntimeInferShapeContext::GetVarType), // NOLINT
this,
std::placeholders::_1));
return retv;
}

Expand Down
3 changes: 1 addition & 2 deletions paddle/phi/core/threadpool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ ThreadPool::ThreadPool(int num_threads) : running_(true) {
threads_.resize(num_threads);
for (auto& thread : threads_) {
// TODO(Yancey1989): binding the thread on the specify CPU numberw
thread =
std::make_unique<std::thread>(std::bind(&ThreadPool::TaskLoop, this));
thread = std::make_unique<std::thread>([this] { ThreadPool::TaskLoop(); });
}
}

Expand Down

0 comments on commit a172e6c

Please sign in to comment.