@@ -1811,6 +1811,30 @@ void CIRGenFunction::buildCXXAggrConstructorCall(
1811
1811
constantCount.erase ();
1812
1812
}
1813
1813
1814
+ static bool canEmitDelegateCallArgs (CIRGenFunction &CGF,
1815
+ const CXXConstructorDecl *Ctor,
1816
+ CXXCtorType Type, CallArgList &Args) {
1817
+ // We can't forward a variadic call.
1818
+ if (Ctor->isVariadic ())
1819
+ return false ;
1820
+
1821
+ if (CGF.getTarget ().getCXXABI ().areArgsDestroyedLeftToRightInCallee ()) {
1822
+ // If the parameters are callee-cleanup, it's not safe to forward.
1823
+ for (auto *P : Ctor->parameters ())
1824
+ if (P->needsDestruction (CGF.getContext ()))
1825
+ return false ;
1826
+
1827
+ // Likewise if they're inalloca.
1828
+ const CIRGenFunctionInfo &Info =
1829
+ CGF.CGM .getTypes ().arrangeCXXConstructorCall (Args, Ctor, Type, 0 , 0 );
1830
+ if (Info.usesInAlloca ())
1831
+ return false ;
1832
+ }
1833
+
1834
+ // Anything else should be OK.
1835
+ return true ;
1836
+ }
1837
+
1814
1838
void CIRGenFunction::buildCXXConstructorCall (const clang::CXXConstructorDecl *D,
1815
1839
clang::CXXCtorType Type,
1816
1840
bool ForVirtualBase,
@@ -1872,7 +1896,14 @@ void CIRGenFunction::buildCXXConstructorCall(
1872
1896
1873
1897
bool PassPrototypeArgs = true ;
1874
1898
1875
- assert (!D->getInheritedConstructor () && " inheritance NYI" );
1899
+ // Check whether we can actually emit the constructor before trying to do so.
1900
+ if (auto Inherited = D->getInheritedConstructor ()) {
1901
+ PassPrototypeArgs = getTypes ().inheritingCtorHasParams (Inherited, Type);
1902
+ if (PassPrototypeArgs && !canEmitDelegateCallArgs (*this , D, Type, Args)) {
1903
+ llvm_unreachable (" NYI" );
1904
+ return ;
1905
+ }
1906
+ }
1876
1907
1877
1908
// Insert any ABI-specific implicit constructor arguments.
1878
1909
CIRGenCXXABI::AddedStructorArgCounts ExtraArgs =
@@ -1891,4 +1922,33 @@ void CIRGenFunction::buildCXXConstructorCall(
1891
1922
ClassDecl->isDynamicClass () || Type == Ctor_Base ||
1892
1923
!CGM.getCodeGenOpts ().StrictVTablePointers &&
1893
1924
" vtable assumption loads NYI" );
1925
+ }
1926
+
1927
+ void CIRGenFunction::buildInheritedCXXConstructorCall (
1928
+ const CXXConstructorDecl *D, bool ForVirtualBase, Address This,
1929
+ bool InheritedFromVBase, const CXXInheritedCtorInitExpr *E) {
1930
+ CallArgList Args;
1931
+ CallArg ThisArg (RValue::get (getAsNaturalPointerTo (
1932
+ This, D->getThisType ()->getPointeeType ())),
1933
+ D->getThisType ());
1934
+
1935
+ // Forward the parameters.
1936
+ if (InheritedFromVBase &&
1937
+ CGM.getTarget ().getCXXABI ().hasConstructorVariants ()) {
1938
+ llvm_unreachable (" NYI" );
1939
+ } else if (!CXXInheritedCtorInitExprArgs.empty ()) {
1940
+ // The inheriting constructor was inlined; just inject its arguments.
1941
+ llvm_unreachable (" NYI" );
1942
+ } else {
1943
+ // The inheriting constructor was not inlined. Emit delegating arguments.
1944
+ llvm_unreachable (" NYI" );
1945
+ }
1946
+
1947
+ llvm_unreachable (" NYI" );
1948
+ }
1949
+
1950
+ void CIRGenFunction::buildInlinedInheritingCXXConstructorCall (
1951
+ const CXXConstructorDecl *Ctor, CXXCtorType CtorType, bool ForVirtualBase,
1952
+ bool Delegating, CallArgList &Args) {
1953
+ llvm_unreachable (" NYI" );
1894
1954
}
0 commit comments