[cfe-commits] r155756 - in /cfe/trunk: include/clang/AST/Type.h lib/AST/Type.cpp lib/Sema/SemaExpr.cpp test/SemaCXX/type-traits.cpp
Benjamin Kramer
benny.kra at googlemail.com
Sun Apr 29 08:20:11 PDT 2012
On 29.04.2012, at 17:13, Douglas Gregor wrote:
> Has this issue manifested in some serious way?
Not so far, got a report of std::is_pod being wrong.
- Ben
>
> Sent from my iPhone
>
> On Apr 29, 2012, at 12:08 AM, Richard Smith <richard at metafoo.co.uk> wrote:
>
>> This is probably not as major as it seems -- PODness doesn't affect C++11 language semantics at all (but does affect some parts of the library, notably std::is_pod). I suspect (but haven't checked!) that many of our uses of isPODType really do want the C++98 definition, even in C++11 mode, or shouldn't be checking for POD at all. Even with this change, CXXRecordDecl::isPOD is using the C++98 definition.
>>
>> On Sat, Apr 28, 2012 at 3:15 AM, Benjamin Kramer <benny.kra at googlemail.com> wrote:
>>
>> On 28.04.2012, at 12:00, Benjamin Kramer wrote:
>>
>> > Author: d0k
>> > Date: Sat Apr 28 05:00:42 2012
>> > New Revision: 155756
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=155756&view=rev
>> > Log:
>> > Rename isPODType (using the C++98 rules) into isCXX98PODType and make isPODType decide which one to use based on LangOptions.
>> >
>> > - -Wc++98-compat depends on the c++98 definition
>> > - Now __is_pod returns the right thing in c++11 and c++98 mode
>> > - All changes to the type traits test are validated against g++ 4.7
>>
>> Doug, can you review/approve this for 3.1? It looks like a pretty major bug.
>>
>> - Ben
>>
>> > Modified:
>> > cfe/trunk/include/clang/AST/Type.h
>> > cfe/trunk/lib/AST/Type.cpp
>> > cfe/trunk/lib/Sema/SemaExpr.cpp
>> > cfe/trunk/test/SemaCXX/type-traits.cpp
>> >
>> > Modified: cfe/trunk/include/clang/AST/Type.h
>> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=155756&r1=155755&r2=155756&view=diff
>> > ==============================================================================
>> > --- cfe/trunk/include/clang/AST/Type.h (original)
>> > +++ cfe/trunk/include/clang/AST/Type.h Sat Apr 28 05:00:42 2012
>> > @@ -634,6 +634,11 @@
>> > /// \brief Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
>> > bool isPODType(ASTContext &Context) const;
>> >
>> > + /// isCXX98PODType() - Return true if this is a POD type according to the
>> > + /// rules of the C++98 standard, regardless of the current compilation's
>> > + /// language.
>> > + bool isCXX98PODType(ASTContext &Context) const;
>> > +
>> > /// isCXX11PODType() - Return true if this is a POD type according to the
>> > /// more relaxed rules of the C++11 standard, regardless of the current
>> > /// compilation's language.
>> >
>> > Modified: cfe/trunk/lib/AST/Type.cpp
>> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=155756&r1=155755&r2=155756&view=diff
>> > ==============================================================================
>> > --- cfe/trunk/lib/AST/Type.cpp (original)
>> > +++ cfe/trunk/lib/AST/Type.cpp Sat Apr 28 05:00:42 2012
>> > @@ -895,6 +895,14 @@
>> > }
>> >
>> > bool QualType::isPODType(ASTContext &Context) const {
>> > + // C++11 has a more relaxed definition of POD.
>> > + if (Context.getLangOpts().CPlusPlus0x)
>> > + return isCXX11PODType(Context);
>> > +
>> > + return isCXX98PODType(Context);
>> > +}
>> > +
>> > +bool QualType::isCXX98PODType(ASTContext &Context) const {
>> > // The compiler shouldn't query this for incomplete types, but the user might.
>> > // We return false for that case. Except for incomplete arrays of PODs, which
>> > // are PODs according to the standard.
>> >
>> > Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
>> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=155756&r1=155755&r2=155756&view=diff
>> > ==============================================================================
>> > --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
>> > +++ cfe/trunk/lib/Sema/SemaExpr.cpp Sat Apr 28 05:00:42 2012
>> > @@ -560,7 +560,8 @@
>> > // Complain about passing non-POD types through varargs. However, don't
>> > // perform this check for incomplete types, which we can get here when we're
>> > // in an unevaluated context.
>> > - if (!E->getType()->isIncompleteType() && !E->getType().isPODType(Context)) {
>> > + if (!E->getType()->isIncompleteType() &&
>> > + !E->getType().isCXX98PODType(Context)) {
>> > // C++0x [expr.call]p7:
>> > // Passing a potentially-evaluated argument of class type (Clause 9)
>> > // having a non-trivial copy constructor, a non-trivial move constructor,
>> >
>> > Modified: cfe/trunk/test/SemaCXX/type-traits.cpp
>> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/type-traits.cpp?rev=155756&r1=155755&r2=155756&view=diff
>> > ==============================================================================
>> > --- cfe/trunk/test/SemaCXX/type-traits.cpp (original)
>> > +++ cfe/trunk/test/SemaCXX/type-traits.cpp Sat Apr 28 05:00:42 2012
>> > @@ -131,25 +131,25 @@
>> > { int arr[T(__is_pod(HasAnonymousUnion))]; }
>> > { int arr[T(__is_pod(Vector))]; }
>> > { int arr[T(__is_pod(VectorExt))]; }
>> > + { int arr[T(__is_pod(Derives))]; }
>> > + { int arr[T(__is_pod(DerivesAr))]; }
>> > + { int arr[T(__is_pod(DerivesArNB))]; }
>> > + { int arr[T(__is_pod(DerivesEmpty))]; }
>> > + { int arr[T(__is_pod(HasPriv))]; }
>> > + { int arr[T(__is_pod(HasProt))]; }
>> > + { int arr[T(__is_pod(DerivesHasPriv))]; }
>> > + { int arr[T(__is_pod(DerivesHasProt))]; }
>> >
>> > - { int arr[F(__is_pod(Derives))]; }
>> > - { int arr[F(__is_pod(DerivesAr))]; }
>> > - { int arr[F(__is_pod(DerivesArNB))]; }
>> > - { int arr[F(__is_pod(DerivesEmpty))]; }
>> > { int arr[F(__is_pod(HasCons))]; }
>> > { int arr[F(__is_pod(HasCopyAssign))]; }
>> > { int arr[F(__is_pod(HasMoveAssign))]; }
>> > { int arr[F(__is_pod(HasDest))]; }
>> > - { int arr[F(__is_pod(HasPriv))]; }
>> > - { int arr[F(__is_pod(HasProt))]; }
>> > { int arr[F(__is_pod(HasRef))]; }
>> > { int arr[F(__is_pod(HasVirt))]; }
>> > { int arr[F(__is_pod(DerivesHasCons))]; }
>> > { int arr[F(__is_pod(DerivesHasCopyAssign))]; }
>> > { int arr[F(__is_pod(DerivesHasMoveAssign))]; }
>> > { int arr[F(__is_pod(DerivesHasDest))]; }
>> > - { int arr[F(__is_pod(DerivesHasPriv))]; }
>> > - { int arr[F(__is_pod(DerivesHasProt))]; }
>> > { int arr[F(__is_pod(DerivesHasRef))]; }
>> > { int arr[F(__is_pod(DerivesHasVirt))]; }
>> > { int arr[F(__is_pod(NonPOD))]; }
>> > @@ -1223,10 +1223,10 @@
>> > { int arr[T(__has_trivial_copy(const Int))]; }
>> > { int arr[T(__has_trivial_copy(AllDefaulted))]; }
>> > { int arr[T(__has_trivial_copy(AllDeleted))]; }
>> > + { int arr[T(__has_trivial_copy(DerivesAr))]; }
>> >
>> > { int arr[F(__has_trivial_copy(HasCopy))]; }
>> > { int arr[F(__has_trivial_copy(HasTemplateCons))]; }
>> > - { int arr[F(__has_trivial_copy(DerivesAr))]; }
>> > { int arr[F(__has_trivial_copy(VirtAr))]; }
>> > { int arr[F(__has_trivial_copy(void))]; }
>> > { int arr[F(__has_trivial_copy(cvoid))]; }
>> > @@ -1250,13 +1250,13 @@
>> > { int arr[T(__has_trivial_assign(HasMoveAssign))]; }
>> > { int arr[T(__has_trivial_assign(AllDefaulted))]; }
>> > { int arr[T(__has_trivial_assign(AllDeleted))]; }
>> > + { int arr[T(__has_trivial_assign(DerivesAr))]; }
>> >
>> > { int arr[F(__has_trivial_assign(IntRef))]; }
>> > { int arr[F(__has_trivial_assign(HasCopyAssign))]; }
>> > { int arr[F(__has_trivial_assign(const Int))]; }
>> > { int arr[F(__has_trivial_assign(ConstIntAr))]; }
>> > { int arr[F(__has_trivial_assign(ConstIntArAr))]; }
>> > - { int arr[F(__has_trivial_assign(DerivesAr))]; }
>> > { int arr[F(__has_trivial_assign(VirtAr))]; }
>> > { int arr[F(__has_trivial_assign(void))]; }
>> > { int arr[F(__has_trivial_assign(cvoid))]; }
>> > @@ -1338,6 +1338,7 @@
>> > { int arr[T(__has_nothrow_assign(HasVirtDest))]; }
>> > { int arr[T(__has_nothrow_assign(AllPrivate))]; }
>> > { int arr[T(__has_nothrow_assign(UsingAssign))]; }
>> > + { int arr[T(__has_nothrow_assign(DerivesAr))]; }
>> >
>> > { int arr[F(__has_nothrow_assign(IntRef))]; }
>> > { int arr[F(__has_nothrow_assign(HasCopyAssign))]; }
>> > @@ -1345,7 +1346,6 @@
>> > { int arr[F(__has_nothrow_assign(const Int))]; }
>> > { int arr[F(__has_nothrow_assign(ConstIntAr))]; }
>> > { int arr[F(__has_nothrow_assign(ConstIntArAr))]; }
>> > - { int arr[F(__has_nothrow_assign(DerivesAr))]; }
>> > { int arr[F(__has_nothrow_assign(VirtAr))]; }
>> > { int arr[F(__has_nothrow_assign(void))]; }
>> > { int arr[F(__has_nothrow_assign(cvoid))]; }
>> > @@ -1375,10 +1375,10 @@
>> > { int arr[T(__has_nothrow_copy(HasVirtDest))]; }
>> > { int arr[T(__has_nothrow_copy(HasTemplateCons))]; }
>> > { int arr[T(__has_nothrow_copy(AllPrivate))]; }
>> > + { int arr[T(__has_nothrow_copy(DerivesAr))]; }
>> >
>> > { int arr[F(__has_nothrow_copy(HasCopy))]; }
>> > { int arr[F(__has_nothrow_copy(HasMultipleCopy))]; }
>> > - { int arr[F(__has_nothrow_copy(DerivesAr))]; }
>> > { int arr[F(__has_nothrow_copy(VirtAr))]; }
>> > { int arr[F(__has_nothrow_copy(void))]; }
>> > { int arr[F(__has_nothrow_copy(cvoid))]; }
>> >
>> >
>> > _______________________________________________
>> > cfe-commits mailing list
>> > cfe-commits at cs.uiuc.edu
>> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
More information about the cfe-commits
mailing list