Skip to content

Commit

Permalink
TEnum::GetUnderlying add support for typedefs.
Browse files Browse the repository at this point in the history
This fixes root-project#15460.

Extend the test accordingly.
  • Loading branch information
pcanal authored and sftnight committed Aug 19, 2024
1 parent 32d25d2 commit 681556b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/meta/test/testTEnum.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ enum class ECull: unsigned long long { kOne };
enum class ECsll: signed long long { kOne };
enum class ECcl: short;
enum class ECtsll : Long64_t { kEtsllOne };
enum class ECtss : int16_t { kEtsllOne };
)CODE"
);

Expand All @@ -63,6 +66,9 @@ enum class ECcl: short;
EXPECT_EQ(TEnum::GetEnum("Eull")->GetUnderlyingType(), kULong64_t);
EXPECT_EQ(TEnum::GetEnum("Esll")->GetUnderlyingType(), kLong64_t);
EXPECT_EQ(TEnum::GetEnum("Ecl")->GetUnderlyingType(), kShort_t);

EXPECT_EQ(TEnum::GetEnum("ECtsll")->GetUnderlyingType(), kLong64_t);
EXPECT_EQ(TEnum::GetEnum("ECtss")->GetUnderlyingType(), kShort_t);
}


Expand Down
2 changes: 2 additions & 0 deletions core/metacling/src/TClingClassInfo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,8 @@ EDataType TClingClassInfo::GetUnderlyingType() const
if (auto ED = llvm::dyn_cast<EnumDecl>(GetDecl())) {
R__LOCKGUARD(gInterpreterMutex);
auto Ty = ED->getIntegerType().getTypePtrOrNull();
if (Ty)
Ty = Ty->getUnqualifiedDesugaredType();
if (auto BTy = llvm::dyn_cast_or_null<BuiltinType>(Ty)) {
switch (BTy->getKind()) {
case BuiltinType::Bool:
Expand Down

0 comments on commit 681556b

Please sign in to comment.