MS ABI: Build C++ default argument exprs for exported template classes

This was an omission from r232229.

llvm-svn: 232554
This commit is contained in:
Reid Kleckner 2015-03-17 21:51:43 +00:00
parent ae14e7bf99
commit 93f661a1da
6 changed files with 21 additions and 5 deletions

View File

@ -5012,7 +5012,7 @@ public:
SourceLocation RBrac,
AttributeList *AttrList);
void ActOnFinishCXXMemberDecls();
void ActOnFinishCXXMethodDefs(Decl *D);
void ActOnFinishCXXMemberDefaultArgs(Decl *D);
void ActOnReenterCXXMethodParameter(Scope *S, ParmVarDecl *Param);
unsigned ActOnReenterTemplateScope(Scope *S, Decl *Template);

View File

@ -3411,8 +3411,11 @@ MicrosoftCXXABI::getAddrOfCXXCtorClosure(const CXXConstructorDecl *CD,
// Add the rest of the default arguments.
std::vector<Stmt *> ArgVec;
for (unsigned I = IsCopy ? 1 : 0, E = CD->getNumParams(); I != E; ++I)
ArgVec.push_back(getContext().getDefaultArgExprForConstructor(CD, I));
for (unsigned I = IsCopy ? 1 : 0, E = CD->getNumParams(); I != E; ++I) {
Stmt *DefaultArg = getContext().getDefaultArgExprForConstructor(CD, I);
assert(DefaultArg && "sema forgot to instantiate default args");
ArgVec.push_back(DefaultArg);
}
CodeGenFunction::RunCleanupsScope Cleanups(CGF);

View File

@ -2918,7 +2918,7 @@ void Parser::ParseCXXMemberSpecification(SourceLocation RecordLoc,
// We've finished parsing everything, including default argument
// initializers.
Actions.ActOnFinishCXXMethodDefs(TagDecl);
Actions.ActOnFinishCXXMemberDefaultArgs(TagDecl);
}
if (TagDecl)

View File

@ -9449,7 +9449,7 @@ static void getDefaultArgExprsForConstructors(Sema &S, CXXRecordDecl *Class) {
}
}
void Sema::ActOnFinishCXXMethodDefs(Decl *D) {
void Sema::ActOnFinishCXXMemberDefaultArgs(Decl *D) {
auto *RD = dyn_cast<CXXRecordDecl>(D);
// Default constructors that are annotated with __declspec(dllexport) which

View File

@ -2043,6 +2043,10 @@ Sema::InstantiateClass(SourceLocation PointOfInstantiation,
SourceLocation(), SourceLocation(), nullptr);
CheckCompletedCXXClass(Instantiation);
// Default arguments are parsed, if not instantiated. We can go instantiate
// default arg exprs for default constructors if necessary now.
ActOnFinishCXXMemberDefaultArgs(Instantiation);
// Instantiate late parsed attributes, and attach them to their decls.
// See Sema::InstantiateAttrs
for (LateInstantiatedAttrVec::iterator I = LateAttrs.begin(),

View File

@ -523,6 +523,15 @@ struct __declspec(dllexport) NestedOuter {
// M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01??_FNestedOuter@@QAEXXZ"
// M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01??_FNestedInner@NestedOuter@@QAEXXZ"
template <typename T>
struct SomeTemplate {
SomeTemplate(T o = T()) : o(o) {}
T o;
};
struct __declspec(dllexport) InheritFromTemplate : SomeTemplate<int> {};
// M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01??_F?$SomeTemplate@H@@QAEXXZ"
struct __declspec(dllexport) T {
// Copy assignment operator:
// M32-DAG: define weak_odr dllexport x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.T* @"\01??4T@@QAEAAU0@ABU0@@Z"