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 (ClassDecl->hasUserProvidedDefaultConstructor())
62 if (ClassDecl->isPolymorphic())
65 if (ClassDecl->hasTrivialDefaultConstructor())
70 for (
const FieldDecl *Field : ClassDecl->fields()) {
71 if (Field->hasInClassInitializer())
77 for (
const CXXBaseSpecifier &
Base : ClassDecl->bases()) {
92 if (Type->isArrayType())
98 if (Type->isIncompleteType())
101 if (Context.getLangOpts().ObjCAutoRefCount) {
102 switch (Type.getObjCLifetime()) {
103 case Qualifiers::OCL_ExplicitNone:
106 case Qualifiers::OCL_Strong:
107 case Qualifiers::OCL_Weak:
108 case Qualifiers::OCL_Autoreleasing:
111 case Qualifiers::OCL_None:
112 if (Type->isObjCLifetimeType())
118 QualType CanonicalType = Type.getCanonicalType();
119 if (CanonicalType->isDependentType())
123 if (CanonicalType->isScalarType() || CanonicalType->isVectorType())
126 if (
const auto *RT = CanonicalType->getAs<RecordType>()) {
135 auto *
Record = Type->getAsCXXRecordDecl();
137 Record->hasNonTrivialMoveConstructor();
141 auto *
Record = Type->getAsCXXRecordDecl();
143 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 hasNonTrivialMoveAssignment(QualType Type)
Return true if Type has a non-trivial move assignment operator.