diff options
| author | David Majnemer <david.majnemer@gmail.com> | 2016-05-13 20:05:09 +0000 |
|---|---|---|
| committer | David Majnemer <david.majnemer@gmail.com> | 2016-05-13 20:05:09 +0000 |
| commit | 833b91eee8c4a33f725f5f22736c85958476f2ec (patch) | |
| tree | ed353c95f74e424b64223e404943ccee8ae50759 /clang/lib | |
| parent | 6ecc10ab8051aba47d575cfcacb3e86385ff920d (diff) | |
| download | bcm5719-llvm-833b91eee8c4a33f725f5f22736c85958476f2ec.tar.gz bcm5719-llvm-833b91eee8c4a33f725f5f22736c85958476f2ec.zip | |
[MS ABI] Delegating constructors should not assume they are most derived
A constructor needs to know whether or not it is most derived in order
to determine if it is responsible for virtual bases. Delegating
constructors assumed they were most derived.
llvm-svn: 269465
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/CodeGen/MicrosoftCXXABI.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp index 0e15f5054d8..2e41f934a2b 100644 --- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp @@ -1467,16 +1467,18 @@ unsigned MicrosoftCXXABI::addImplicitConstructorArgs( // Add the 'most_derived' argument second if we are variadic or last if not. const FunctionProtoType *FPT = D->getType()->castAs<FunctionProtoType>(); - llvm::Value *MostDerivedArg = - llvm::ConstantInt::get(CGM.Int32Ty, Type == Ctor_Complete); - RValue RV = RValue::get(MostDerivedArg); - if (MostDerivedArg) { - if (FPT->isVariadic()) - Args.insert(Args.begin() + 1, - CallArg(RV, getContext().IntTy, /*needscopy=*/false)); - else - Args.add(RV, getContext().IntTy); + llvm::Value *MostDerivedArg; + if (Delegating) { + MostDerivedArg = getStructorImplicitParamValue(CGF); + } else { + MostDerivedArg = llvm::ConstantInt::get(CGM.Int32Ty, Type == Ctor_Complete); } + RValue RV = RValue::get(MostDerivedArg); + if (FPT->isVariadic()) + Args.insert(Args.begin() + 1, + CallArg(RV, getContext().IntTy, /*needscopy=*/false)); + else + Args.add(RV, getContext().IntTy); return 1; // Added one arg. } |

