r232554 - MS ABI: Build C++ default argument exprs for exported template classes
Reid Kleckner
reid at kleckner.net
Tue Mar 17 14:51:43 PDT 2015
Author: rnk
Date: Tue Mar 17 16:51:43 2015
New Revision: 232554
URL: http://llvm.org/viewvc/llvm-project?rev=232554&view=rev
Log:
MS ABI: Build C++ default argument exprs for exported template classes
This was an omission from r232229.
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/test/CodeGenCXX/dllexport.cpp
Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=232554&r1=232553&r2=232554&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Mar 17 16:51:43 2015
@@ -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);
Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=232554&r1=232553&r2=232554&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Tue Mar 17 16:51:43 2015
@@ -3411,8 +3411,11 @@ MicrosoftCXXABI::getAddrOfCXXCtorClosure
// 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);
Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=232554&r1=232553&r2=232554&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Tue Mar 17 16:51:43 2015
@@ -2918,7 +2918,7 @@ void Parser::ParseCXXMemberSpecification
// We've finished parsing everything, including default argument
// initializers.
- Actions.ActOnFinishCXXMethodDefs(TagDecl);
+ Actions.ActOnFinishCXXMemberDefaultArgs(TagDecl);
}
if (TagDecl)
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=232554&r1=232553&r2=232554&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Mar 17 16:51:43 2015
@@ -9449,7 +9449,7 @@ static void getDefaultArgExprsForConstru
}
}
-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
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=232554&r1=232553&r2=232554&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Tue Mar 17 16:51:43 2015
@@ -2043,6 +2043,10 @@ Sema::InstantiateClass(SourceLocation Po
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(),
Modified: cfe/trunk/test/CodeGenCXX/dllexport.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllexport.cpp?rev=232554&r1=232553&r2=232554&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/dllexport.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/dllexport.cpp Tue Mar 17 16:51:43 2015
@@ -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 at 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 at 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 at ABU0@@Z"
More information about the cfe-commits
mailing list