Skip to content

Commit

Permalink
Return aliases through 'members_of'.
Browse files Browse the repository at this point in the history
Closes #42.
  • Loading branch information
katzdm committed May 19, 2024
1 parent c2764ac commit e7d7620
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
5 changes: 0 additions & 5 deletions clang/lib/Sema/Metafunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1256,11 +1256,6 @@ bool map_decl_to_entity(APValue &Result, Sema &S, EvalFn Evaluator,

if (auto *TyDecl = dyn_cast<TypeDecl>(D)) {
QualType QT = S.Context.getTypeDeclType(TyDecl);
if (auto *TDND = dyn_cast<TypedefNameDecl>(TyDecl)) {
auto TSI = TDND->getTypeSourceInfo();
assert(TSI);
QT = TSI->getType();
}
return SetAndSucceed(Result, makeReflection(QT));
} else if (auto *TDecl = dyn_cast<TemplateDecl>(D)) {
TemplateName TName(TDecl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,18 @@ struct Cls : NotAMember {
template <typename T> void TMemFn();

struct Inner { int c; };

using Alias = int;
};

static_assert(members_of(^Cls).size() == 12);
static_assert(members_of(^Cls).size() == 13);
static_assert(nonstatic_data_members_of(^Cls) ==
std::vector{^Cls::mem1, ^Cls::mem2});
static_assert(static_data_members_of(^Cls) == std::vector{^Cls::smem});
static_assert(members_of(^Cls, std::meta::is_constructor).size() == 2);
static_assert(members_of(^Cls, std::meta::is_destructor).size() == 1);
static_assert(members_of(^Cls, std::meta::is_type) == std::vector{^Cls::Inner});
static_assert(members_of(^Cls, std::meta::is_type) == std::vector{^Cls::Inner,
^Cls::Alias});
static_assert(members_of(^Cls, std::meta::is_template) ==
std::vector{^Cls::TMemFn});
static_assert(members_of(^Cls, std::meta::is_function,
Expand All @@ -70,6 +73,7 @@ static_assert(members_of(^Cls, std::meta::is_function,
[](auto R) { return !is_static_member(R) &&
!is_special_member(R); }) ==
std::vector{^Cls::memfn1, ^Cls::memfn2});
static_assert(members_of(^Cls, std::meta::is_alias)[0] == ^Cls::Alias);

template <typename T>
struct TCls {
Expand All @@ -96,7 +100,7 @@ void usage_example() {
return members_of(^Cls, std::meta::is_type).size();
};

static_assert(1 == getSz());
static_assert(2 == getSz());
static_assert(^Cls::Inner == members_of(^Cls, std::meta::is_type)[0]);

constexpr auto getInnerObj = []() consteval {
Expand Down

0 comments on commit e7d7620

Please sign in to comment.