[libcxx] r296561 - Fix PR32097 - is_abstract doesn't work on class templates.

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 1 09:08:10 PST 2017


We're at the "should have tagged 'final' days ago" stage :-)

Since it's not a regression, I would prefer not to merge it unless you
feel super strongly about it.

Sounds like a good candidate for 4.0.1 (tracking bug is PR32061).

Thanks,
Hans

On Wed, Mar 1, 2017 at 1:36 AM, Eric Fiselier <eric at efcs.ca> wrote:
> @Hans Where are we in the release process? I would like to merge this into
> 4.0.
>
> Although it's not a regression, it is a significant bug. This patch fixes
> the bug by
> forwarding to a compiler builtin, which is strictly better than what we
> have. I'm
> confident this patch is safe.
>
> /Eric
>
> On Tue, Feb 28, 2017 at 6:27 PM, Eric Fiselier via cfe-commits
> <cfe-commits at lists.llvm.org> wrote:
>>
>> Author: ericwf
>> Date: Tue Feb 28 19:27:14 2017
>> New Revision: 296561
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=296561&view=rev
>> Log:
>> Fix PR32097 - is_abstract doesn't work on class templates.
>>
>> This patch fixes llvm.org/PR32097 by using the __is_abstract
>> builtin type-trait instead of the previous library-only implementation.
>>
>> All supported compilers provide this trait. I've tested as far
>> back as Clang 3.2, GCC 4.6 and MSVC trunk.
>>
>> Modified:
>>     libcxx/trunk/include/type_traits
>>
>> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp
>>
>> Modified: libcxx/trunk/include/type_traits
>> URL:
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=296561&r1=296560&r2=296561&view=diff
>>
>> ==============================================================================
>> --- libcxx/trunk/include/type_traits (original)
>> +++ libcxx/trunk/include/type_traits Tue Feb 28 19:27:14 2017
>> @@ -1297,18 +1297,8 @@ template <class _Tp> using decay_t = typ
>>
>>  // is_abstract
>>
>> -namespace __is_abstract_imp
>> -{
>> -template <class _Tp> char  __test(_Tp (*)[1]);
>> -template <class _Tp> __two __test(...);
>> -}
>> -
>> -template <class _Tp, bool = is_class<_Tp>::value>
>> -struct __libcpp_abstract : public integral_constant<bool,
>> sizeof(__is_abstract_imp::__test<_Tp>(0)) != 1> {};
>> -
>> -template <class _Tp> struct __libcpp_abstract<_Tp, false> : public
>> false_type {};
>> -
>> -template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract : public
>> __libcpp_abstract<_Tp> {};
>> +template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract
>> +    : public integral_constant<bool, __is_abstract(_Tp)> {};
>>
>>  #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
>>  template <class _Tp> _LIBCPP_CONSTEXPR bool is_abstract_v
>>
>> Modified:
>> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp?rev=296561&r1=296560&r2=296561&view=diff
>>
>> ==============================================================================
>> ---
>> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp
>> (original)
>> +++
>> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp
>> Tue Feb 28 19:27:14 2017
>> @@ -65,6 +65,14 @@ class Abstract
>>      virtual ~Abstract() = 0;
>>  };
>>
>> +template <class>
>> +struct AbstractTemplate {
>> +  virtual void test() = 0;
>> +};
>> +
>> +template <>
>> +struct AbstractTemplate<double> {};
>> +
>>  int main()
>>  {
>>      test_is_not_abstract<void>();
>> @@ -81,4 +89,6 @@ int main()
>>      test_is_not_abstract<NotEmpty>();
>>
>>      test_is_abstract<Abstract>();
>> +    test_is_abstract<AbstractTemplate<int> >();
>> +    test_is_not_abstract<AbstractTemplate<double> >();
>>  }
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>


More information about the cfe-commits mailing list