[Sema] Replace mem_fn with lambdas. NFC.

I'm told that some optimizers like lambdas a lot more than mem_fn.
Given that the readability difference is basically nil, and we seem to
use lambdas basically everywhere else, it seems sensible to just use
lambdas.

llvm-svn: 276577
This commit is contained in:
George Burgess IV
2016-07-24 23:12:40 +00:00
parent 19244b67bc
commit 21081364f8
2 changed files with 11 additions and 7 deletions

View File

@@ -1144,14 +1144,16 @@ void Sema::ActOnLambdaError(SourceLocation StartLoc, Scope *CurScope,
/// \brief Add a lambda's conversion to function pointer, as described in
/// C++11 [expr.prim.lambda]p6.
static void addFunctionPointerConversion(Sema &S,
static void addFunctionPointerConversion(Sema &S,
SourceRange IntroducerRange,
CXXRecordDecl *Class,
CXXMethodDecl *CallOperator) {
// This conversion is explicitly disabled if the lambda's function has
// pass_object_size attributes on any of its parameters.
if (llvm::any_of(CallOperator->parameters(),
std::mem_fn(&ParmVarDecl::hasAttr<PassObjectSizeAttr>)))
auto HasPassObjectSizeAttr = [](const ParmVarDecl *P) {
return P->hasAttr<PassObjectSizeAttr>();
};
if (llvm::any_of(CallOperator->parameters(), HasPassObjectSizeAttr))
return;
// Add the conversion to function pointer.

View File

@@ -39,8 +39,9 @@ using namespace clang;
using namespace sema;
static bool functionHasPassObjectSizeParams(const FunctionDecl *FD) {
return llvm::any_of(FD->parameters(),
std::mem_fn(&ParmVarDecl::hasAttr<PassObjectSizeAttr>));
return llvm::any_of(FD->parameters(), [](const ParmVarDecl *P) {
return P->hasAttr<PassObjectSizeAttr>();
});
}
/// A convenience routine for creating a decayed reference to a function.
@@ -8954,8 +8955,9 @@ static bool checkAddressOfFunctionIsAvailable(Sema &S, const FunctionDecl *FD,
return false;
}
auto I = llvm::find_if(
FD->parameters(), std::mem_fn(&ParmVarDecl::hasAttr<PassObjectSizeAttr>));
auto I = llvm::find_if(FD->parameters(), [](const ParmVarDecl *P) {
return P->hasAttr<PassObjectSizeAttr>();
});
if (I == FD->param_end())
return true;