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

Rafael Avila de Espindola via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 10 14:57:48 PDT 2018


espindola accepted this revision.
espindola added a comment.
This revision is now accepted and ready to land.

LGTM



================
Comment at: ELF/LinkerScript.h:317
 
+template <class CmdType> static auto filter(ArrayRef<BaseCommand *> V) {
+  struct Iter
----------------
grimar wrote:
> 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.
Good question. It might be a good idea to ask on llvm-dev. At least the clang build is still using -std=c++11.


https://reviews.llvm.org/D45166





More information about the llvm-commits mailing list