From: Richard Smith Date: Thu, 23 Mar 2017 23:17:58 +0000 (+0000) Subject: Remove all uses of std::mem_fun and std::bind1st removed in C++17. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cdf35e9aba5a5b25ec24e656ce92bba9d9555a02;p=clang Remove all uses of std::mem_fun and std::bind1st removed in C++17. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@298657 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/DeclContextInternals.h b/include/clang/AST/DeclContextInternals.h index ff37758c25..eb86526e8e 100644 --- a/include/clang/AST/DeclContextInternals.h +++ b/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/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index c2a09cd88a..26c0cbe82d 100644 --- a/include/clang/AST/DeclObjC.h +++ b/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/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h b/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h index aaecf38f33..fa7ee62ab7 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h +++ b/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/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp index e56fe2c1c1..7e8d516180 100644 --- a/lib/CodeGen/CGCall.cpp +++ b/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/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index 1677d340fb..057e43f211 100644 --- a/lib/Sema/Sema.cpp +++ b/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) {