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:
@@ -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() &&
|
||||
|
||||
Reference in New Issue
Block a user