From bd1bb9df54172ce46b81536c3bcde0f4116ebb4a Mon Sep 17 00:00:00 2001 From: George Burgess IV Date: Sun, 24 Jul 2016 23:12:40 +0000 Subject: [PATCH] [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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@276577 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaLambda.cpp | 8 +++++--- lib/Sema/SemaOverload.cpp | 10 ++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/Sema/SemaLambda.cpp b/lib/Sema/SemaLambda.cpp index 1b8410d7f4..472637ba80 100644 --- a/lib/Sema/SemaLambda.cpp +++ b/lib/Sema/SemaLambda.cpp @@ -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))) + auto HasPassObjectSizeAttr = [](const ParmVarDecl *P) { + return P->hasAttr(); + }; + if (llvm::any_of(CallOperator->parameters(), HasPassObjectSizeAttr)) return; // Add the conversion to function pointer. diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index dfb4cceddf..090fab7d35 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -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)); + return llvm::any_of(FD->parameters(), [](const ParmVarDecl *P) { + return P->hasAttr(); + }); } /// 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)); + auto I = llvm::find_if(FD->parameters(), [](const ParmVarDecl *P) { + return P->hasAttr(); + }); if (I == FD->param_end()) return true; -- 2.40.0