11 #include "clang/AST/ASTContext.h" 12 #include "clang/AST/DeclCXX.h" 13 #include "clang/ASTMatchers/ASTMatchFinder.h" 18 namespace type_traits {
22 bool classHasTrivialCopyAndDestroy(QualType Type) {
23 auto *
Record = Type->getAsCXXRecordDecl();
25 !
Record->hasNonTrivialCopyConstructor() &&
26 !
Record->hasNonTrivialDestructor();
29 bool hasDeletedCopyConstructor(QualType Type) {
30 auto *
Record = Type->getAsCXXRecordDecl();
33 for (
const auto *Constructor :
Record->ctors()) {
34 if (Constructor->isCopyConstructor() && Constructor->isDeleted())
43 const ASTContext &Context) {
44 if (Type->isDependentType() || Type->isIncompleteType())
46 return !Type.isTriviallyCopyableType(Context) &&
47 !classHasTrivialCopyAndDestroy(Type) &&
48 !hasDeletedCopyConstructor(Type) &&
49 !Type->isObjCLifetimeType();
53 const ASTContext &Context) {
54 const auto *ClassDecl = dyn_cast<CXXRecordDecl>(&RecordDecl);
60 if (ClassDecl->hasUserProvidedDefaultConstructor())
63 if (ClassDecl->isPolymorphic())
66 if (ClassDecl->hasTrivialDefaultConstructor())
71 for (
const FieldDecl *Field : ClassDecl->fields()) {
72 if (Field->hasInClassInitializer())
78 for (
const CXXBaseSpecifier &Base : ClassDecl->bases()) {
93 if (Type->isArrayType())
99 if (Type->isIncompleteType())
102 if (Context.getLangOpts().ObjCAutoRefCount) {
103 switch (Type.getObjCLifetime()) {
104 case Qualifiers::OCL_ExplicitNone:
107 case Qualifiers::OCL_Strong:
108 case Qualifiers::OCL_Weak:
109 case Qualifiers::OCL_Autoreleasing:
112 case Qualifiers::OCL_None:
113 if (Type->isObjCLifetimeType())
119 QualType CanonicalType = Type.getCanonicalType();
120 if (CanonicalType->isDependentType())
124 if (CanonicalType->isScalarType() || CanonicalType->isVectorType())
127 if (
const auto *RT = CanonicalType->getAs<RecordType>()) {
136 auto *
Record = Type->getAsCXXRecordDecl();
138 Record->hasNonTrivialMoveConstructor();
142 auto *
Record = Type->getAsCXXRecordDecl();
144 Record->hasNonTrivialMoveAssignment();
llvm::SmallVector< uint64_t, 1024 > Record
bool hasNonTrivialMoveConstructor(QualType Type)
Returns true if Type has a non-trivial move constructor.
bool recordIsTriviallyDefaultConstructible(const RecordDecl &RecordDecl, const ASTContext &Context)
Returns true if RecordDecl is trivially default constructible.
llvm::Optional< bool > isExpensiveToCopy(QualType Type, const ASTContext &Context)
Returns true if Type is expensive to copy.
bool isTriviallyDefaultConstructible(QualType Type, const ASTContext &Context)
Returns true if Type is trivially default constructible.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
bool hasNonTrivialMoveAssignment(QualType Type)
Return true if Type has a non-trivial move assignment operator.