[llvm] r290680 - [NewGVN] replace typedefs with usings

Piotr Padlewski via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 28 14:27:35 PST 2016


2 main reasons why using is better:
- it is cleaner, specially in cases like
  using vptr = void (*)(int);
- it works with templates
template <typename T>
using MyVec = std::SmallVector<T, 10>;

I will try to start thread soon about changing coding standards to use
these features more conservatively in new code.

I guess the only reason why people use typedefs is just habbits, but this
is easy to change.


2016-12-28 23:05 GMT+01:00 Sanjoy Das <sanjoy at playingwithpointers.com>:

> Hi Piotr,
>
> Is there a tangible benefit to doing this replacement?
>
> I'd rather not have the codebase be a mix of typedefs and using
> directives.  If one is more preferable than the other for some reason
> then we should note that in the coding style and slowly migrate the
> whole codebase towards that.
>
> -- Sanjoy
>
> On Wed, Dec 28, 2016 at 11:29 AM, Piotr Padlewski via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
> > Author: prazek
> > Date: Wed Dec 28 13:29:26 2016
> > New Revision: 290680
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=290680&view=rev
> > Log:
> > [NewGVN] replace typedefs with usings
> >
> > Modified:
> >     llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp
> >
> > Modified: llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp
> > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/
> Transforms/Scalar/NewGVN.cpp?rev=290680&r1=290679&r2=290680&view=diff
> > ============================================================
> ==================
> > --- llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp (original)
> > +++ llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp Wed Dec 28 13:29:26 2016
> > @@ -120,7 +120,7 @@ PHIExpression::~PHIExpression() = defaul
> >  // propagation and reassociation of values.
> >  //
> >  struct CongruenceClass {
> > -  typedef SmallPtrSet<Value *, 4> MemberSet;
> > +  using MemberSet = SmallPtrSet<Value *, 4>;
> >    unsigned ID;
> >    // Representative leader.
> >    Value *RepLeader = nullptr;
> > @@ -192,7 +192,7 @@ class NewGVN : public FunctionPass {
> >    DenseMap<MemoryAccess *, MemoryAccess *> MemoryAccessEquiv;
> >
> >    // Expression to class mapping.
> > -  typedef DenseMap<const Expression *, CongruenceClass *>
> ExpressionClassMap;
> > +  using ExpressionClassMap = DenseMap<const Expression *,
> CongruenceClass *>;
> >    ExpressionClassMap ExpressionToClass;
> >
> >    // Which values have changed as a result of leader changes.
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
>
>
> --
> Sanjoy Das
> http://playingwithpointers.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161228/629cb55e/attachment.html>


More information about the llvm-commits mailing list