diff options
Diffstat (limited to 'clang/lib/AST/DeclCXX.cpp')
-rw-r--r-- | clang/lib/AST/DeclCXX.cpp | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp index 3eaf301d7a8..12d715e0684 100644 --- a/clang/lib/AST/DeclCXX.cpp +++ b/clang/lib/AST/DeclCXX.cpp @@ -40,9 +40,8 @@ CXXRecordDecl::CXXRecordDecl(TagKind TK, DeclContext *DC, SourceLocation L, IdentifierInfo *Id) : RecordDecl(CXXRecord, TK, DC, L, Id), UserDeclaredConstructor(false), UserDeclaredCopyConstructor(false), - Aggregate(true), Polymorphic(false), Bases(0), NumBases(0), - Constructors(DC, DeclarationName()), - Destructor(0), + UserDeclaredDestructor(false), Aggregate(true), Polymorphic(false), + Bases(0), NumBases(0), Conversions(DC, DeclarationName()) { } CXXRecordDecl *CXXRecordDecl::Create(ASTContext &C, TagKind TK, DeclContext *DC, @@ -58,18 +57,6 @@ CXXRecordDecl::~CXXRecordDecl() { delete [] Bases; } -void CXXRecordDecl::Destroy(ASTContext &C) { - for (OverloadedFunctionDecl::function_iterator func - = Constructors.function_begin(); - func != Constructors.function_end(); ++func) - (*func)->Destroy(C); - - if (isDefinition()) - Destructor->Destroy(C); - - RecordDecl::Destroy(C); -} - void CXXRecordDecl::setBases(CXXBaseSpecifier const * const *Bases, unsigned NumBases) { @@ -88,20 +75,35 @@ CXXRecordDecl::setBases(CXXBaseSpecifier const * const *Bases, } bool CXXRecordDecl::hasConstCopyConstructor(ASTContext &Context) const { - for (OverloadedFunctionDecl::function_const_iterator Con - = Constructors.function_begin(); - Con != Constructors.function_end(); ++Con) { - unsigned TypeQuals; + QualType ClassType = Context.getTypeDeclType(const_cast<CXXRecordDecl*>(this)); + DeclarationName ConstructorName + = Context.DeclarationNames.getCXXConstructorName( + Context.getCanonicalType(ClassType)); + unsigned TypeQuals; + DeclContext::lookup_const_result Lookup + = this->lookup(Context, ConstructorName); + if (Lookup.first == Lookup.second) + return false; + else if (OverloadedFunctionDecl *Constructors + = dyn_cast<OverloadedFunctionDecl>(*Lookup.first)) { + for (OverloadedFunctionDecl::function_const_iterator Con + = Constructors->function_begin(); + Con != Constructors->function_end(); ++Con) { if (cast<CXXConstructorDecl>(*Con)->isCopyConstructor(Context, TypeQuals) && (TypeQuals & QualType::Const != 0)) return true; + } + } else if (CXXConstructorDecl *Constructor + = dyn_cast<CXXConstructorDecl>(*Lookup.first)) { + return Constructor->isCopyConstructor(Context, TypeQuals) && + (TypeQuals & QualType::Const != 0); } return false; } void -CXXRecordDecl::addConstructor(ASTContext &Context, - CXXConstructorDecl *ConDecl) { +CXXRecordDecl::addedConstructor(ASTContext &Context, + CXXConstructorDecl *ConDecl) { if (!ConDecl->isImplicitlyDeclared()) { // Note that we have a user-declared constructor. UserDeclaredConstructor = true; @@ -116,8 +118,6 @@ CXXRecordDecl::addConstructor(ASTContext &Context, if (ConDecl->isCopyConstructor(Context)) UserDeclaredCopyConstructor = true; } - - Constructors.addOverload(ConDecl); } void CXXRecordDecl::addConversionFunction(ASTContext &Context, |