Skip to content

Commit 645ce23

Browse files
committed
Mangle reflections of constructors and destructors correctly.
Fixes #54.
1 parent 0994a5a commit 645ce23

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

clang/lib/AST/ItaniumMangle.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -4694,6 +4694,12 @@ void CXXNameMangler::mangleReflection(const ReflectionValue &R) {
46944694
Decl *D = R.getAsDecl();
46954695
if (auto * ED = dyn_cast<EnumConstantDecl>(D)) {
46964696
mangleIntegerLiteral(ED->getType(), ED->getInitVal());
4697+
} else if (auto *CD = dyn_cast<CXXConstructorDecl>(D)) {
4698+
GlobalDecl GD(CD, Ctor_Complete);
4699+
mangle(GD);
4700+
} else if (auto *DD = dyn_cast<CXXDestructorDecl>(D)) {
4701+
GlobalDecl GD(DD, Dtor_Complete);
4702+
mangle(GD);
46974703
} else {
46984704
mangle(cast<NamedDecl>(D));
46994705
}

libcxx/test/std/experimental/reflection/template-arguments.pass.cpp

+18-2
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,24 @@ template<class T> struct TCls {};
194194
TCls<int> obj1;
195195
TCls<decltype(obj1)> obj2;
196196

197-
static_assert(has_template_arguments(template_arguments_of(^decltype(obj2))[0]) ==
198-
has_template_arguments(^TCls<int>));
197+
static_assert(
198+
has_template_arguments(template_arguments_of(^decltype(obj2))[0]) ==
199+
has_template_arguments(^TCls<int>));
199200
} // namespace bb_clang_p2996_issue_41_regression_test
200201

202+
// =======================================
203+
// bb_clang_p2996_issue_54_regression_test
204+
// =======================================
205+
206+
namespace bb_clang_p2996_issue_54_regression_test {
207+
template <auto R> void fn() { }
208+
209+
void fn() {
210+
class S { S(); ~S(); };
211+
fn<members_of(^S, std::meta::is_constructor)[0]>();
212+
fn<members_of(^S, std::meta::is_destructor)[0]>();
213+
}
214+
} // namespace bb_clang_p2996_issue_54_regression_test
215+
216+
201217
int main() { }

0 commit comments

Comments
 (0)