On Apr 23, 2011, at 3:47 AM, Chandler Carruth wrote: > Author: chandlerc > Date: Sat Apr 23 05:47:28 2011 > New Revision: 130057 > > URL: http://llvm.org/viewvc/llvm-project?rev=130057&view=rev > Log: > Implement basic __is_trivial type-trait support, enough to close PR9472. > This introduces a few APIs on the AST to bundle up the standard-based > logic so that programmatic clients have access to exactly the same > behavior.
Thanks! > There is only one serious FIXME here: checking for non-trivial move > constructors and move assignment operators. Those bits need to be added > to the declaration and accessors provided. At the moment, all move constructors and move-assignment operators are non-trivial, since we haven't implemented the implicit declaration or definition of move constructors or move-assignment operators. > Modified: cfe/trunk/lib/AST/DeclCXX.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=130057&r1=130056&r2=130057&view=diff > ============================================================================== > --- cfe/trunk/lib/AST/DeclCXX.cpp (original) > +++ cfe/trunk/lib/AST/DeclCXX.cpp Sat Apr 23 05:47:28 2011 > @@ -217,6 +217,23 @@ > return getCopyConstructor(Context, Qualifiers::Const) != 0; > } > > +bool CXXRecordDecl::isTriviallyCopyable() const { > + // C++0x [class]p5: > + // A trivially copyable class is a class that: > + // -- has no non-trivial copy constructors, > + if (!hasTrivialCopyConstructor()) return false; > + // -- has no non-trivial move constructors, > + // FIXME: C++0x: Track and check trivial move constructors. > + // -- has no non-trivial copy assignment operators, > + if (!hasTrivialCopyAssignment()) return false; > + // -- has no non-trivial move assignment operators, and > + // FIXME: C++0x: Track and check trivial move assignment operators. > + // -- has a trivial destructor. > + if (!hasTrivialDestructor()) return false; > + > + return true; > +} In the near term, the best approach here would be to add and maintain UserDeclaredMoveConstructor and UserDeclaredMoveAssignment bits to CXXRecordDecl::DefinitionData, and have hasTrivialMoveConstructor()/hasTrivialMoveAssignment() just check those. That way, the semantics of __is_trivial will be consistent. - Doug _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
