diff options
author | David Majnemer <david.majnemer@gmail.com> | 2014-09-11 23:05:02 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2014-09-11 23:05:02 +0000 |
commit | 196ac334f32f81d9fe040d51de4117c86c7087bf (patch) | |
tree | 1ed72f0ee4a978653049c6ecf2be7dc0b266250d /clang/lib/CodeGen/CGClass.cpp | |
parent | 42fa4af8fe4e672d0b8bd4a5ebeec9b45730a0ff (diff) | |
download | bcm5719-llvm-196ac334f32f81d9fe040d51de4117c86c7087bf.tar.gz bcm5719-llvm-196ac334f32f81d9fe040d51de4117c86c7087bf.zip |
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
Diffstat (limited to 'clang/lib/CodeGen/CGClass.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGClass.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp index 1de325feea3..72869d8ca9b 100644 --- a/clang/lib/CodeGen/CGClass.cpp +++ b/clang/lib/CodeGen/CGClass.cpp @@ -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() && |