r270580 - [Lex] Support more type-traits in __has_feature

David Majnemer via cfe-commits cfe-commits at lists.llvm.org
Tue May 24 10:28:28 PDT 2016


Done with r270583, I added a note in a comment to avoid this situation in
the future.

On Tue, May 24, 2016 at 10:26 AM, Richard Smith <richard at metafoo.co.uk>
wrote:

> On 24 May 2016 10:15 a.m., "Richard Smith" <richard at metafoo.co.uk> wrote:
> >
> > As I recall, this was intentional. The supported way to check for these
> is has_builtin. The has_feature support is provided only for backwards
> compatibility.
>
> See documentation here:
>
> http://clang.llvm.org/docs/LanguageExtensions.html#checks-for-type-trait-primitives
>
> These should be covered only by has_extension, not by has_feature.
>
> > On 24 May 2016 9:59 a.m., "David Majnemer via cfe-commits" <
> cfe-commits at lists.llvm.org> wrote:
> >>
> >> Author: majnemer
> >> Date: Tue May 24 11:53:13 2016
> >> New Revision: 270580
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=270580&view=rev
> >> Log:
> >> [Lex] Support more type-traits in __has_feature
> >>
> >> It looks like we forgot to update the __has_feature support when we
> >> added some of the type traits.
> >>
> >> Modified:
> >>     cfe/trunk/lib/Lex/PPMacroExpansion.cpp
> >>     cfe/trunk/test/Lexer/has_feature_type_traits.cpp
> >>
> >> Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
> >> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=270580&r1=270579&r2=270580&view=diff
> >>
> ==============================================================================
> >> --- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
> >> +++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Tue May 24 11:53:13 2016
> >> @@ -1191,8 +1191,10 @@ static bool HasFeature(const Preprocesso
> >>        .Case("has_nothrow_copy", LangOpts.CPlusPlus)
> >>        .Case("has_nothrow_constructor", LangOpts.CPlusPlus)
> >>        .Case("has_trivial_assign", LangOpts.CPlusPlus)
> >> +      .Case("has_trivial_move_assign", LangOpts.CPlusPlus)
> >>        .Case("has_trivial_copy", LangOpts.CPlusPlus)
> >>        .Case("has_trivial_constructor", LangOpts.CPlusPlus)
> >> +      .Case("has_trivial_move_constructor", LangOpts.CPlusPlus)
> >>        .Case("has_trivial_destructor", LangOpts.CPlusPlus)
> >>        .Case("has_virtual_destructor", LangOpts.CPlusPlus)
> >>        .Case("is_abstract", LangOpts.CPlusPlus)
> >> @@ -1201,14 +1203,21 @@ static bool HasFeature(const Preprocesso
> >>        .Case("is_class", LangOpts.CPlusPlus)
> >>        .Case("is_constructible", LangOpts.CPlusPlus)
> >>        .Case("is_convertible_to", LangOpts.CPlusPlus)
> >> +      .Case("is_destructible",
> >> +            LangOpts.CPlusPlus &&LangOpts.MicrosoftExt)
> >>        .Case("is_empty", LangOpts.CPlusPlus)
> >>        .Case("is_enum", LangOpts.CPlusPlus)
> >>        .Case("is_final", LangOpts.CPlusPlus)
> >>        .Case("is_literal", LangOpts.CPlusPlus)
> >> -      .Case("is_standard_layout", LangOpts.CPlusPlus)
> >> +      .Case("is_nothrow_assignable", LangOpts.CPlusPlus)
> >> +      .Case("is_nothrow_constructible", LangOpts.CPlusPlus)
> >> +      .Case("is_nothrow_destructible",
> >> +            LangOpts.CPlusPlus && LangOpts.MicrosoftExt)
> >>        .Case("is_pod", LangOpts.CPlusPlus)
> >>        .Case("is_polymorphic", LangOpts.CPlusPlus)
> >> -      .Case("is_sealed", LangOpts.MicrosoftExt)
> >> +      .Case("is_sealed",
> >> +            LangOpts.CPlusPlus && LangOpts.MicrosoftExt)
> >> +      .Case("is_standard_layout", LangOpts.CPlusPlus)
> >>        .Case("is_trivial", LangOpts.CPlusPlus)
> >>        .Case("is_trivially_assignable", LangOpts.CPlusPlus)
> >>        .Case("is_trivially_constructible", LangOpts.CPlusPlus)
> >>
> >> Modified: cfe/trunk/test/Lexer/has_feature_type_traits.cpp
> >> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/has_feature_type_traits.cpp?rev=270580&r1=270579&r2=270580&view=diff
> >>
> ==============================================================================
> >> --- cfe/trunk/test/Lexer/has_feature_type_traits.cpp (original)
> >> +++ cfe/trunk/test/Lexer/has_feature_type_traits.cpp Tue May 24
> 11:53:13 2016
> >> @@ -20,6 +20,16 @@ int has_trivial_assign();
> >>  #endif
> >>  // CHECK: int has_trivial_assign();
> >>
> >> +#if __has_feature(has_trivial_move_assign)
> >> +int has_trivial_move_assign();
> >> +#endif
> >> +// CHECK: int has_trivial_move_assign();
> >> +
> >> +#if __has_feature(has_trivial_move_constructor)
> >> +int has_trivial_move_constructor();
> >> +#endif
> >> +// CHECK: int has_trivial_move_constructor();
> >> +
> >>  #if __has_feature(has_trivial_copy)
> >>  int has_trivial_copy();
> >>  #endif
> >> @@ -105,6 +115,16 @@ int is_literal();
> >>  #endif
> >>  // CHECK: int is_literal();
> >>
> >> +#if __has_feature(is_nothrow_assignable)
> >> +int is_nothrow_assignable();
> >> +#endif
> >> +// CHECK: int is_nothrow_assignable();
> >> +
> >> +#if __has_feature(is_nothrow_constructible)
> >> +int is_nothrow_constructible();
> >> +#endif
> >> +// CHECK: int is_nothrow_constructible();
> >> +
> >>  #if __has_feature(is_standard_layout)
> >>  int is_standard_layout();
> >>  #endif
> >>
> >>
> >> _______________________________________________
> >> cfe-commits mailing list
> >> cfe-commits at lists.llvm.org
> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160524/f856033b/attachment-0001.html>


More information about the cfe-commits mailing list