Skip to content

Commit 67bbd1e

Browse files
authored
[CIR] [CodeGen] Handle arrangeCXXStructorDeclaration (#1179)
Removes some NYIs. But left assert(false) due to missing tests. It looks better since it is not so scaring as NYI.
1 parent 7cbfe8e commit 67bbd1e

File tree

2 files changed

+31
-9
lines changed

2 files changed

+31
-9
lines changed

clang/lib/CIR/CodeGen/CIRGenCall.cpp

+20-9
Original file line numberDiff line numberDiff line change
@@ -1193,19 +1193,30 @@ CIRGenTypes::arrangeCXXStructorDeclaration(GlobalDecl GD) {
11931193

11941194
CIRGenCXXABI::AddedStructorArgCounts AddedArgs =
11951195
TheCXXABI.buildStructorSignature(GD, argTypes);
1196-
(void)AddedArgs;
1197-
assert(paramInfos.empty() && "NYI");
1196+
if (!paramInfos.empty()) {
1197+
// Note: prefix implies after the first param.
1198+
if (AddedArgs.Prefix)
1199+
paramInfos.insert(paramInfos.begin() + 1, AddedArgs.Prefix,
1200+
FunctionProtoType::ExtParameterInfo{});
1201+
if (AddedArgs.Suffix)
1202+
paramInfos.append(AddedArgs.Suffix,
1203+
FunctionProtoType::ExtParameterInfo{});
1204+
1205+
assert(false && "Please sent PR with a test and remove this");
1206+
}
11981207

1199-
assert(!MD->isVariadic() && "Variadic fns NYI");
1200-
RequiredArgs required = RequiredArgs::All;
1201-
(void)required;
1208+
RequiredArgs required =
1209+
(PassParams && MD->isVariadic() ? RequiredArgs(argTypes.size())
1210+
: RequiredArgs::All);
12021211

12031212
FunctionType::ExtInfo extInfo = FTP->getExtInfo();
1213+
CanQualType resultType = TheCXXABI.HasThisReturn(GD) ? argTypes.front()
1214+
: TheCXXABI.hasMostDerivedReturn(GD)
1215+
? Context.VoidPtrTy
1216+
: Context.VoidTy;
12041217

1205-
assert(!TheCXXABI.HasThisReturn(GD) && "NYI");
1206-
1207-
CanQualType resultType = Context.VoidTy;
1208-
(void)resultType;
1218+
assert(!TheCXXABI.HasThisReturn(GD) &&
1219+
"Please sent PR with a test and remove this");
12091220

12101221
return arrangeCIRFunctionInfo(resultType, cir::FnInfoOpts::IsInstanceMethod,
12111222
argTypes, extInfo, paramInfos, required);
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %clang_cc1 -std=c++20 -fclangir -emit-cir -triple x86_64-unknown-linux-gnu %s -o %t.cir
2+
// RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR
3+
4+
class A {
5+
public:
6+
A(void *, ...);
7+
};
8+
9+
A a(nullptr, 1, "str");
10+
11+
// CIR: cir.func private @_ZN1AC1EPvz(!cir.ptr<!ty_A>, !cir.ptr<!void>, ...)

0 commit comments

Comments
 (0)