[clang] 6170072 - Improve modeling of variable template specializations with dependent

Martin Storsjö via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 11 00:29:13 PDT 2020


On Sun, 9 Aug 2020, Richard Smith via cfe-commits wrote:

>
> Author: Richard Smith
> Date: 2020-08-09T23:22:26-07:00
> New Revision: 617007240cbfb97c8ccf6d61b0c4ca0bb62d43c9
>
> URL: https://github.com/llvm/llvm-project/commit/617007240cbfb97c8ccf6d61b0c4ca0bb62d43c9
> DIFF: https://github.com/llvm/llvm-project/commit/617007240cbfb97c8ccf6d61b0c4ca0bb62d43c9.diff
>
> LOG: Improve modeling of variable template specializations with dependent
> arguments.
>
> Don't build a variable template specialization declaration until its
> scope and template arguments are non-dependent.
>
> No functionality change intended, but the AST representation is now more
> consistent with how we model other templates.

This did turn out to make a functional change, breaking building the dev 
branch of Qt. A halfway reduced example below:


template <class _Tp, _Tp __v>
struct integral_constant
{
   static constexpr const _Tp value = __v;
   typedef _Tp value_type;
   typedef integral_constant type;
   __attribute__ ((__exclude_from_explicit_instantiation__))
   constexpr operator value_type() const noexcept {return value;}

   __attribute__ ((__exclude_from_explicit_instantiation__))
   constexpr value_type operator ()() const noexcept {return value;}
};


template <class _Tp, class _Arg>
struct is_nothrow_assignable
     : public integral_constant<bool, __is_nothrow_assignable(_Tp, _Arg)> 
{};
template <class _Tp, class _Arg>
inline constexpr bool is_nothrow_assignable_v
     = is_nothrow_assignable<_Tp, _Arg>::value;


template <class T>
class QCache
{
     struct Value {
         T *t = nullptr;
     };

     struct Node {
         Value value;

         void replace(const Value &t) noexcept(is_nothrow_assignable_v<T>) {
             value = t;
         }
     };

};



// Martin



More information about the cfe-commits mailing list