diff options
Diffstat (limited to 'contrib/llvm/tools/clang/include/clang/AST/DeclCXX.h')
-rw-r--r-- | contrib/llvm/tools/clang/include/clang/AST/DeclCXX.h | 113 |
1 files changed, 99 insertions, 14 deletions
diff --git a/contrib/llvm/tools/clang/include/clang/AST/DeclCXX.h b/contrib/llvm/tools/clang/include/clang/AST/DeclCXX.h index dd490f4..7e60773 100644 --- a/contrib/llvm/tools/clang/include/clang/AST/DeclCXX.h +++ b/contrib/llvm/tools/clang/include/clang/AST/DeclCXX.h @@ -363,10 +363,10 @@ class CXXRecordDecl : public RecordDecl { /// default constructor. bool HasTrivialDefaultConstructor : 1; - /// HasConstExprNonCopyMoveConstructor - True when this class has at least + /// HasConstexprNonCopyMoveConstructor - True when this class has at least /// one constexpr constructor which is neither the copy nor move /// constructor. - bool HasConstExprNonCopyMoveConstructor : 1; + bool HasConstexprNonCopyMoveConstructor : 1; /// HasTrivialCopyConstructor - True when this class has a trivial copy /// constructor. @@ -468,6 +468,14 @@ class CXXRecordDecl : public RecordDecl { /// \brief Whether we have already declared a destructor within the class. bool DeclaredDestructor : 1; + /// \brief Whether an implicit move constructor was attempted to be declared + /// but would have been deleted. + bool FailedImplicitMoveConstructor : 1; + + /// \brief Whether an implicit move assignment operator was attempted to be + /// declared but would have been deleted. + bool FailedImplicitMoveAssignment : 1; + /// NumBases - The number of base class specifiers in Bases. unsigned NumBases; @@ -780,6 +788,33 @@ public: return data().DeclaredMoveConstructor; } + /// \brief Determine whether implicit move constructor generation for this + /// class has failed before. + bool hasFailedImplicitMoveConstructor() const { + return data().FailedImplicitMoveConstructor; + } + + /// \brief Set whether implicit move constructor generation for this class + /// has failed before. + void setFailedImplicitMoveConstructor(bool Failed = true) { + data().FailedImplicitMoveConstructor = Failed; + } + + /// \brief Determine whether this class should get an implicit move + /// constructor or if any existing special member function inhibits this. + /// + /// Covers all bullets of C++0x [class.copy]p9 except the last, that the + /// constructor wouldn't be deleted, which is only looked up from a cached + /// result. + bool needsImplicitMoveConstructor() const { + return !hasFailedImplicitMoveConstructor() && + !hasDeclaredMoveConstructor() && + !hasUserDeclaredCopyConstructor() && + !hasUserDeclaredCopyAssignment() && + !hasUserDeclaredMoveAssignment() && + !hasUserDeclaredDestructor(); + } + /// hasUserDeclaredCopyAssignment - Whether this class has a /// user-declared copy assignment operator. When false, a copy /// assigment operator will be implicitly declared. @@ -807,6 +842,33 @@ public: return data().DeclaredMoveAssignment; } + /// \brief Determine whether implicit move assignment generation for this + /// class has failed before. + bool hasFailedImplicitMoveAssignment() const { + return data().FailedImplicitMoveAssignment; + } + + /// \brief Set whether implicit move assignment generation for this class + /// has failed before. + void setFailedImplicitMoveAssignment(bool Failed = true) { + data().FailedImplicitMoveAssignment = Failed; + } + + /// \brief Determine whether this class should get an implicit move + /// assignment operator or if any existing special member function inhibits + /// this. + /// + /// Covers all bullets of C++0x [class.copy]p20 except the last, that the + /// constructor wouldn't be deleted. + bool needsImplicitMoveAssignment() const { + return !hasFailedImplicitMoveAssignment() && + !hasDeclaredMoveAssignment() && + !hasUserDeclaredCopyConstructor() && + !hasUserDeclaredCopyAssignment() && + !hasUserDeclaredMoveConstructor() && + !hasUserDeclaredDestructor(); + } + /// hasUserDeclaredDestructor - Whether this class has a /// user-declared destructor. When false, a destructor will be /// implicitly declared. @@ -889,10 +951,10 @@ public: data().DeclaredDefaultConstructor); } - // hasConstExprNonCopyMoveConstructor - Whether this class has at least one - // constexpr constructor other than the copy or move constructors - bool hasConstExprNonCopyMoveConstructor() const { - return data().HasConstExprNonCopyMoveConstructor; + // hasConstexprNonCopyMoveConstructor - Whether this class has at least one + // constexpr constructor other than the copy or move constructors. + bool hasConstexprNonCopyMoveConstructor() const { + return data().HasConstexprNonCopyMoveConstructor; } // hasTrivialCopyConstructor - Whether this class has a trivial copy @@ -942,6 +1004,25 @@ public: return isTriviallyCopyable() && hasTrivialDefaultConstructor(); } + // isLiteral - Whether this class is a literal type. + // + // C++0x [basic.types]p10 + // A class type that has all the following properties: + // -- a trivial destructor + // -- every constructor call and full-expression in the + // brace-or-equal-intializers for non-static data members (if any) is + // a constant expression. + // -- it is an aggregate type or has at least one constexpr constructor or + // constructor template that is not a copy or move constructor, and + // -- all non-static data members and base classes of literal types + // + // We resolve DR1361 by ignoring the second bullet. + bool isLiteral() const { + return hasTrivialDestructor() && + (isAggregate() || hasConstexprNonCopyMoveConstructor()) && + !hasNonLiteralTypeFieldsOrBases(); + } + /// \brief If this record is an instantiation of a member class, /// retrieves the member class from which it was instantiated. /// @@ -1237,10 +1318,10 @@ protected: const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isStatic, StorageClass SCAsWritten, bool isInline, - SourceLocation EndLocation) + bool isConstexpr, SourceLocation EndLocation) : FunctionDecl(DK, RD, StartLoc, NameInfo, T, TInfo, (isStatic ? SC_Static : SC_None), - SCAsWritten, isInline) { + SCAsWritten, isInline, isConstexpr) { if (EndLocation.isValid()) setRangeEnd(EndLocation); } @@ -1253,6 +1334,7 @@ public: bool isStatic, StorageClass SCAsWritten, bool isInline, + bool isConstexpr, SourceLocation EndLocation); bool isStatic() const { return getStorageClass() == SC_Static; } @@ -1333,6 +1415,7 @@ public: /// void g() &&; /// void h(); /// }; + /// \endcode RefQualifierKind getRefQualifier() const { return getType()->getAs<FunctionProtoType>()->getRefQualifier(); } @@ -1630,9 +1713,9 @@ class CXXConstructorDecl : public CXXMethodDecl { const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isExplicitSpecified, bool isInline, - bool isImplicitlyDeclared) + bool isImplicitlyDeclared, bool isConstexpr) : CXXMethodDecl(CXXConstructor, RD, StartLoc, NameInfo, T, TInfo, false, - SC_None, isInline, SourceLocation()), + SC_None, isInline, isConstexpr, SourceLocation()), IsExplicitSpecified(isExplicitSpecified), ImplicitlyDefined(false), CtorInitializers(0), NumCtorInitializers(0) { setImplicit(isImplicitlyDeclared); @@ -1645,7 +1728,8 @@ public: const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isExplicit, - bool isInline, bool isImplicitlyDeclared); + bool isInline, bool isImplicitlyDeclared, + bool isConstexpr); /// isExplicitSpecified - Whether this constructor declaration has the /// 'explicit' keyword specified. @@ -1853,7 +1937,7 @@ class CXXDestructorDecl : public CXXMethodDecl { QualType T, TypeSourceInfo *TInfo, bool isInline, bool isImplicitlyDeclared) : CXXMethodDecl(CXXDestructor, RD, StartLoc, NameInfo, T, TInfo, false, - SC_None, isInline, SourceLocation()), + SC_None, isInline, /*isConstexpr=*/false, SourceLocation()), ImplicitlyDefined(false), OperatorDelete(0) { setImplicit(isImplicitlyDeclared); } @@ -1916,9 +2000,9 @@ class CXXConversionDecl : public CXXMethodDecl { const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isInline, bool isExplicitSpecified, - SourceLocation EndLocation) + bool isConstexpr, SourceLocation EndLocation) : CXXMethodDecl(CXXConversion, RD, StartLoc, NameInfo, T, TInfo, false, - SC_None, isInline, EndLocation), + SC_None, isInline, isConstexpr, EndLocation), IsExplicitSpecified(isExplicitSpecified) { } public: @@ -1928,6 +2012,7 @@ public: const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isInline, bool isExplicit, + bool isConstexpr, SourceLocation EndLocation); /// IsExplicitSpecified - Whether this conversion function declaration is |