[PATCH] D45166: [ELF] - Introduce helper for iterating over linker commands.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 10 08:09:26 PDT 2018


grimar added inline comments.


================
Comment at: ELF/LinkerScript.h:317
 
+template <class CmdType> static auto filter(ArrayRef<BaseCommand *> V) {
+  struct Iter
----------------
espindola wrote:
> s/static/inline, no?
> 
> Using auto as a return type is c++14 according to clang. 
> 
> This could probably use a map + filter:
> 
>   template <class CmdType>
>   using Foo = llvm::filter_iterator<ArrayRef<BaseCommand *>::iterator,
>                                   decltype(&dynCastToCmdType<CmdType>)>;
> 
>   template <class CmdType>
>   using Bar =
>     llvm::mapped_iterator<Foo<CmdType>, decltype(dynCastToCmdType<CmdType>) *>;
> 
>   template <class CmdType>
>   llvm::iterator_range<Bar<CmdType>> filter(ArrayRef<BaseCommand *> V) {
> 
> But it feels like some of this code should be in LLVM. In particular, LLVM should probably have
> 
> * a make_mapped_range function
> * type alias for filter_iterator_range
> 
> Using auto as a return type is c++14 according to clang.

I thought we can use c++14 features as long as minimal versions of clang/gcc version accept it.
Not 100% sure that is the case for `auto` though honestly.


https://reviews.llvm.org/D45166





More information about the llvm-commits mailing list