10 #include "clang/AST/ASTContext.h" 11 #include "clang/AST/DeclCXX.h" 12 #include "clang/ASTMatchers/ASTMatchFinder.h" 17 namespace type_traits {
21 bool classHasTrivialCopyAndDestroy(QualType
Type) {
22 auto *
Record = Type->getAsCXXRecordDecl();
24 !
Record->hasNonTrivialCopyConstructor() &&
25 !
Record->hasNonTrivialDestructor();
28 bool hasDeletedCopyConstructor(QualType Type) {
29 auto *
Record = Type->getAsCXXRecordDecl();
32 for (
const auto *Constructor :
Record->ctors()) {
33 if (Constructor->isCopyConstructor() && Constructor->isDeleted())
42 const ASTContext &Context) {
43 if (Type->isDependentType() || Type->isIncompleteType())
45 return !Type.isTriviallyCopyableType(Context) &&
46 !classHasTrivialCopyAndDestroy(Type) &&
47 !hasDeletedCopyConstructor(Type) &&
48 !Type->isObjCLifetimeType();
52 const ASTContext &Context) {
53 const auto *ClassDecl = dyn_cast<CXXRecordDecl>(&RecordDecl);
59 if (RecordDecl.isInvalidDecl())
63 if (ClassDecl->hasUserProvidedDefaultConstructor())
66 if (ClassDecl->isPolymorphic())
69 if (ClassDecl->hasTrivialDefaultConstructor())
74 for (
const FieldDecl *Field : ClassDecl->fields()) {
75 if (Field->hasInClassInitializer())
81 for (
const CXXBaseSpecifier &
Base : ClassDecl->bases()) {
96 if (Type->isArrayType())
102 if (Type->isIncompleteType())
105 if (Context.getLangOpts().ObjCAutoRefCount) {
106 switch (Type.getObjCLifetime()) {
107 case Qualifiers::OCL_ExplicitNone:
110 case Qualifiers::OCL_Strong:
111 case Qualifiers::OCL_Weak:
112 case Qualifiers::OCL_Autoreleasing:
115 case Qualifiers::OCL_None:
116 if (Type->isObjCLifetimeType())
122 QualType CanonicalType = Type.getCanonicalType();
123 if (CanonicalType->isDependentType())
127 if (CanonicalType->isScalarType() || CanonicalType->isVectorType())
130 if (
const auto *RT = CanonicalType->getAs<RecordType>()) {
143 if (Type->isIncompleteType())
146 if (Type.getCanonicalType()->isDependentType())
149 return Type.isDestructedType() == QualType::DK_none;
153 auto *
Record = Type->getAsCXXRecordDecl();
155 Record->hasNonTrivialMoveConstructor();
159 auto *
Record = Type->getAsCXXRecordDecl();
161 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++ -*-===//
std::unique_ptr< GlobalCompilationDatabase > Base
bool isTriviallyDestructible(QualType Type)
Returns true if Type is trivially destructible.
bool hasNonTrivialMoveAssignment(QualType Type)
Return true if Type has a non-trivial move assignment operator.