summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp b/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
index c7c51a25e99..2b9a4827d12 100644
--- a/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
@@ -108,8 +108,9 @@ void AvoidBindCheck::registerMatchers(MatchFinder *Finder) {
return;
Finder->addMatcher(
- callExpr(callee(namedDecl(hasName("::std::bind"))),
- hasArgument(0, declRefExpr(to(functionDecl().bind("f")))))
+ callExpr(
+ callee(namedDecl(hasName("::std::bind"))),
+ hasArgument(0, declRefExpr(to(functionDecl().bind("f"))).bind("ref")))
.bind("bind"),
this);
}
@@ -148,14 +149,17 @@ void AvoidBindCheck::check(const MatchFinder::MatchResult &Result) {
bool HasCapturedArgument = llvm::any_of(
Args, [](const BindArgument &B) { return B.Kind == BK_Other; });
-
+ const auto *Ref = Result.Nodes.getNodeAs<DeclRefExpr>("ref");
Stream << "[" << (HasCapturedArgument ? "=" : "") << "]";
addPlaceholderArgs(Args, Stream);
- Stream << " { return " << F->getName() << "(";
+ Stream << " { return ";
+ Ref->printPretty(Stream, nullptr, Result.Context->getPrintingPolicy());
+ Stream<< "(";
addFunctionCallArgs(Args, Stream);
Stream << "); };";
- Diag << FixItHint::CreateReplacement(MatchedDecl->getSourceRange(), Stream.str());
+ Diag << FixItHint::CreateReplacement(MatchedDecl->getSourceRange(),
+ Stream.str());
}
} // namespace modernize
OpenPOWER on IntegriCloud