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>.
llvm-svn: 114889
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index f629722..207edde 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -778,6 +778,14 @@
} else {
FirstDecl = LastDecl = D;
}
+
+ if (CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(this)) {
+ Decl *InnerD = D;
+ if (FunctionTemplateDecl *FunTmpl = dyn_cast<FunctionTemplateDecl>(D))
+ InnerD = FunTmpl->getTemplatedDecl();
+ if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(InnerD))
+ Record->addedConstructor(Constructor);
+ }
}
void DeclContext::addDecl(Decl *D) {