Clean up the handling of the DeclaredDefaultConstructor and
DeclaredCopyConstructor bits in CXXRecordDecl's DefinitionData
structure. Rather than having Sema call addedConstructor or set the
bits directly at semi-random places, move all of the logic for
managing these bits into CXXRecordDecl itself and tie the
addedConstructor call into DeclContext::addDecl().
This makes it easier for AST-building clients to get the right bits
set in DefinitionData, and is one small part of <rdar://problem/8459981>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114889 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp
index 88301c2..ffdb98d 100644
--- a/lib/AST/DeclCXX.cpp
+++ b/lib/AST/DeclCXX.cpp
@@ -259,9 +259,25 @@
}
void
-CXXRecordDecl::addedConstructor(ASTContext &Context,
- CXXConstructorDecl *ConDecl) {
- assert(!ConDecl->isImplicit() && "addedConstructor - not for implicit decl");
+CXXRecordDecl::addedConstructor(CXXConstructorDecl *Constructor) {
+ // Ignore friends.
+ if (Constructor->getFriendObjectKind())
+ return;
+
+ if (Constructor->isImplicit()) {
+ // If this is the implicit default constructor, note that we have now
+ // declared it.
+ if (Constructor->isDefaultConstructor())
+ data().DeclaredDefaultConstructor = true;
+ // If this is the implicit copy constructor, note that we have now
+ // declared it.
+ else if (Constructor->isCopyConstructor())
+ data().DeclaredCopyConstructor = true;
+
+ // Nothing else to do for implicitly-declared constructors.
+ return;
+ }
+
// Note that we have a user-declared constructor.
data().UserDeclaredConstructor = true;
@@ -285,7 +301,8 @@
// Note when we have a user-declared copy constructor, which will
// suppress the implicit declaration of a copy constructor.
- if (ConDecl->isCopyConstructor()) {
+ if (!Constructor->getDescribedFunctionTemplate() &&
+ Constructor->isCopyConstructor()) {
data().UserDeclaredCopyConstructor = true;
data().DeclaredCopyConstructor = true;
@@ -293,7 +310,6 @@
// A copy constructor is trivial if it is implicitly declared.
// FIXME: C++0x: don't do this for "= default" copy constructors.
data().HasTrivialCopyConstructor = false;
-
}
}