r229374 - ASTMatchers: Replace enable_if with static_assert.

Richard Smith richard at metafoo.co.uk
Wed Mar 4 14:37:58 PST 2015


On Thu, Feb 19, 2015 at 4:02 AM, Benjamin Kramer <benny.kra at gmail.com>
wrote:

> > On 19.02.2015, at 03:07, Richard Smith <richard at metafoo.co.uk> wrote:
> >
> > On Mon, Feb 16, 2015 at 3:08 AM, Benjamin Kramer <
> benny.kra at googlemail.com> wrote:
> > Author: d0k
> > Date: Mon Feb 16 05:08:00 2015
> > New Revision: 229374
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=229374&view=rev
> > Log:
> > ASTMatchers: Replace enable_if with static_assert.
> >
> > This is nicer in general and gives a better error message, but it also
> might
> > bring MSVC 2013 back to life.
> >
> > Modified:
> >     cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
> >
> > Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h?rev=229374&r1=229373&r2=229374&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h (original)
> > +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h Mon Feb 16
> 05:08:00 2015
> > @@ -1178,14 +1178,10 @@ template <unsigned MinCount, unsigned Ma
> >  struct VariadicOperatorMatcherFunc {
> >    DynTypedMatcher::VariadicOperator Op;
> >
> > -  template <unsigned Count, typename T>
> > -  struct EnableIfValidArity
> > -      : public std::enable_if<MinCount <= Count && Count <= MaxCount,
> T> {};
> > -
> >    template <typename... Ms>
> > -  typename EnableIfValidArity<sizeof...(Ms),
> > -                              VariadicOperatorMatcher<Ms...>>::type
> > -  operator()(Ms &&... Ps) const {
> > +  VariadicOperatorMatcher<Ms...> operator()(Ms &&... Ps) const {
> >
> > Why the space after the '...'? That seems to be in conflict with the
> usual LLVM style.
>
> Lacking precedent in LLVM I let clang-format decide how to format this
> piece of code. If LLVM's style prefers to leave out the space we should fix
> clang-format first ;)


Yes, I strongly believe this is a clang-format bug. The ellipsis binds even
tighter to the right than * and & do; it makes no sense to put a space
after it for bind-to-the-right formatting. To drive the point home,
consider this:

  template<typename T> void f(int *...fp(T))

This is a pack of functions each of which returns 'int *'. That is, the ...
binds closest, then the (T), then the *. It is highly misleading to format
that as

  template<typename T> void f(int *... fp(T))

... especially since we'd put the * closer than that if the ... were
absent. (I think the space should go to the left of the ... even in styles
that normally put the space on the right, but I don't think I'm likely to
win that argument.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150304/8d067627/attachment.html>


More information about the cfe-commits mailing list