diff options
author | David Majnemer <david.majnemer@gmail.com> | 2015-03-13 22:36:55 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2015-03-13 22:36:55 +0000 |
commit | 810def84aca2e23a9e028a422820fed0c1b97500 (patch) | |
tree | 5c30a11cf194637a72cb8cb241d80cf866075b37 /lib/CodeGen/CGCall.cpp | |
parent | adb43a714e316ac58c03232e53d18cf6483b8252 (diff) |
MS ABI: Generate default constructor closures
The MS ABI utilizes a compiler generated function called the "vector
constructor iterator" to construct arrays of objects with
non-trivial constructors/destructors. For this to work, the constructor
must follow a specific calling convention. A thunk must be created if
the default constructor has default arguments, is variadic or is
otherwise incompatible. This thunk is called the default constructor
closure.
N.B. Default constructor closures are only generated if the default
constructor is exported because clang itself does not utilize vector
constructor iterators. Failing to export the default constructor
closure will result in link/load failure if a translation unit compiled
with MSVC is on the import side.
Differential Revision: http://reviews.llvm.org/D8331
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@232229 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGCall.cpp')
-rw-r--r-- | lib/CodeGen/CGCall.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp index 6784964211..3cb72bd151 100644 --- a/lib/CodeGen/CGCall.cpp +++ b/lib/CodeGen/CGCall.cpp @@ -347,12 +347,16 @@ CodeGenTypes::arrangeMSMemberPointerThunk(const CXXMethodDecl *MD) { } const CGFunctionInfo & -CodeGenTypes::arrangeMSCopyCtorClosure(const CXXConstructorDecl *CD) { +CodeGenTypes::arrangeMSCtorClosure(const CXXConstructorDecl *CD, + CXXCtorType CT) { + assert(CT == Ctor_CopyingClosure || CT == Ctor_DefaultClosure); + CanQual<FunctionProtoType> FTP = GetFormalType(CD); SmallVector<CanQualType, 2> ArgTys; const CXXRecordDecl *RD = CD->getParent(); ArgTys.push_back(GetThisType(Context, RD)); - ArgTys.push_back(*FTP->param_type_begin()); + if (CT == Ctor_CopyingClosure) + ArgTys.push_back(*FTP->param_type_begin()); if (RD->getNumVBases() > 0) ArgTys.push_back(Context.IntTy); CallingConv CC = Context.getDefaultCallingConvention( |