MS ABI: Use the correct this arg when generating implict copy ctor

We assumed that the incoming this argument would be the last argument.

However, this is not true under the MS ABI.

This fixes PR20897.

llvm-svn: 217642
This commit is contained in:
David Majnemer
2014-09-11 23:05:02 +00:00
parent 42fa4af8fe
commit 196ac334f3
5 changed files with 43 additions and 4 deletions

View File

@@ -914,11 +914,12 @@ namespace {
private:
/// Get source argument for copy constructor. Returns null if not a copy
/// constructor.
static const VarDecl* getTrivialCopySource(const CXXConstructorDecl *CD,
/// constructor.
static const VarDecl *getTrivialCopySource(CodeGenFunction &CGF,
const CXXConstructorDecl *CD,
FunctionArgList &Args) {
if (CD->isCopyOrMoveConstructor() && CD->isDefaulted())
return Args[Args.size() - 1];
return Args[CGF.CGM.getCXXABI().getSrcArgforCopyCtor(CD, Args)];
return nullptr;
}
@@ -949,7 +950,7 @@ namespace {
public:
ConstructorMemcpyizer(CodeGenFunction &CGF, const CXXConstructorDecl *CD,
FunctionArgList &Args)
: FieldMemcpyizer(CGF, CD->getParent(), getTrivialCopySource(CD, Args)),
: FieldMemcpyizer(CGF, CD->getParent(), getTrivialCopySource(CGF, CD, Args)),
ConstructorDecl(CD),
MemcpyableCtor(CD->isDefaulted() &&
CD->isCopyOrMoveConstructor() &&