From 2c27df7603750a91546808be8891c5dd4ddc1a46 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 23 Mar 2017 23:17:58 +0000 Subject: [PATCH] Remove all uses of std::mem_fun and std::bind1st removed in C++17. llvm-svn: 298657 --- clang/include/clang/AST/DeclContextInternals.h | 2 +- clang/include/clang/AST/DeclObjC.h | 12 +++++++----- .../clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h | 12 ++++++------ clang/lib/CodeGen/CGCall.cpp | 2 +- clang/lib/Sema/Sema.cpp | 4 +++- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/clang/include/clang/AST/DeclContextInternals.h b/clang/include/clang/AST/DeclContextInternals.h index ff37758..eb86526 100644 --- a/clang/include/clang/AST/DeclContextInternals.h +++ b/clang/include/clang/AST/DeclContextInternals.h @@ -131,7 +131,7 @@ public: } else { DeclsTy &Vec = *getAsVector(); Vec.erase(std::remove_if(Vec.begin(), Vec.end(), - std::mem_fun(&Decl::isFromASTFile)), + [](Decl *D) { return D->isFromASTFile(); }), Vec.end()); // Don't have any external decls any more. Data = DeclsAndHasExternalTy(&Vec, false); diff --git a/clang/include/clang/AST/DeclObjC.h b/clang/include/clang/AST/DeclObjC.h index c2a09cd..26c0cbe 100644 --- a/clang/include/clang/AST/DeclObjC.h +++ b/clang/include/clang/AST/DeclObjC.h @@ -381,15 +381,17 @@ public: ArrayRef SelLocs = llvm::None); // Iterator access to parameter types. - typedef std::const_mem_fun_t deref_fun; - typedef llvm::mapped_iterator - param_type_iterator; + struct GetTypeFn { + QualType operator()(const ParmVarDecl *PD) const { return PD->getType(); } + }; + typedef llvm::mapped_iterator + param_type_iterator; param_type_iterator param_type_begin() const { - return llvm::map_iterator(param_begin(), deref_fun(&ParmVarDecl::getType)); + return llvm::map_iterator(param_begin(), GetTypeFn()); } param_type_iterator param_type_end() const { - return llvm::map_iterator(param_end(), deref_fun(&ParmVarDecl::getType)); + return llvm::map_iterator(param_end(), GetTypeFn()); } /// createImplicitParams - Used to lazily create the self and cmd diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h index aaecf38..fa7ee62 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h @@ -383,7 +383,9 @@ public: // Iterator access to formal parameters and their types. private: - typedef std::const_mem_fun_t get_type_fun; + struct GetTypeFn { + QualType operator()(ParmVarDecl *PD) const { return PD->getType(); } + }; public: /// Return call's formal parameters. @@ -393,7 +395,7 @@ public: /// correspond with the argument value returned by \c getArgSVal(0). virtual ArrayRef parameters() const = 0; - typedef llvm::mapped_iterator::iterator, get_type_fun> + typedef llvm::mapped_iterator::iterator, GetTypeFn> param_type_iterator; /// Returns an iterator over the types of the call's formal parameters. @@ -402,13 +404,11 @@ public: /// definition because it represents a public interface, and probably has /// more annotations. param_type_iterator param_type_begin() const { - return llvm::map_iterator(parameters().begin(), - get_type_fun(&ParmVarDecl::getType)); + return llvm::map_iterator(parameters().begin(), GetTypeFn()); } /// \sa param_type_begin() param_type_iterator param_type_end() const { - return llvm::map_iterator(parameters().end(), - get_type_fun(&ParmVarDecl::getType)); + return llvm::map_iterator(parameters().end(), GetTypeFn()); } // For debugging purposes only diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index e56fe2c..7e8d516 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -719,7 +719,7 @@ CodeGenTypes::arrangeLLVMFunctionInfo(CanQualType resultType, ArrayRef paramInfos, RequiredArgs required) { assert(std::all_of(argTypes.begin(), argTypes.end(), - std::mem_fun_ref(&CanQualType::isCanonicalAsParam))); + [](CanQualType T) { return T.isCanonicalAsParam(); })); // Lookup or create unique function info. llvm::FoldingSetNodeID ID; diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index 1677d34..057e43f 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -744,7 +744,9 @@ void Sema::ActOnEndOfTranslationUnit() { UnusedFileScopedDecls.erase( std::remove_if(UnusedFileScopedDecls.begin(nullptr, true), UnusedFileScopedDecls.end(), - std::bind1st(std::ptr_fun(ShouldRemoveFromUnused), this)), + [this](const DeclaratorDecl *DD) { + return ShouldRemoveFromUnused(this, DD); + }), UnusedFileScopedDecls.end()); if (TUKind == TU_Prefix) { -- 2.7.4