Skip to content

Commit

Permalink
Mangle reflections of constructors and destructors correctly.
Browse files Browse the repository at this point in the history
Fixes llvm#54.
  • Loading branch information
katzdm committed May 30, 2024
1 parent 0994a5a commit 645ce23
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
6 changes: 6 additions & 0 deletions clang/lib/AST/ItaniumMangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4694,6 +4694,12 @@ void CXXNameMangler::mangleReflection(const ReflectionValue &R) {
Decl *D = R.getAsDecl();
if (auto * ED = dyn_cast<EnumConstantDecl>(D)) {
mangleIntegerLiteral(ED->getType(), ED->getInitVal());
} else if (auto *CD = dyn_cast<CXXConstructorDecl>(D)) {
GlobalDecl GD(CD, Ctor_Complete);
mangle(GD);
} else if (auto *DD = dyn_cast<CXXDestructorDecl>(D)) {
GlobalDecl GD(DD, Dtor_Complete);
mangle(GD);
} else {
mangle(cast<NamedDecl>(D));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,24 @@ template<class T> struct TCls {};
TCls<int> obj1;
TCls<decltype(obj1)> obj2;

static_assert(has_template_arguments(template_arguments_of(^decltype(obj2))[0]) ==
has_template_arguments(^TCls<int>));
static_assert(
has_template_arguments(template_arguments_of(^decltype(obj2))[0]) ==
has_template_arguments(^TCls<int>));
} // namespace bb_clang_p2996_issue_41_regression_test

// =======================================
// bb_clang_p2996_issue_54_regression_test
// =======================================

namespace bb_clang_p2996_issue_54_regression_test {
template <auto R> void fn() { }

void fn() {
class S { S(); ~S(); };
fn<members_of(^S, std::meta::is_constructor)[0]>();
fn<members_of(^S, std::meta::is_destructor)[0]>();
}
} // namespace bb_clang_p2996_issue_54_regression_test


int main() { }

0 comments on commit 645ce23

Please sign in to comment.