Skip to content

Commit 3474903

Browse files
fix: JITCall codegen to deal with enums and funcs with same name (#652)
1 parent 4114c14 commit 3474903

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/CppInterOp/CppInterOp.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,6 +1837,7 @@ void get_type_as_string(QualType QT, std::string& type_name, ASTContext& C,
18371837
#if CLANG_VERSION_MAJOR > 16
18381838
Policy.SuppressElaboration = true;
18391839
#endif
1840+
Policy.SuppressTagKeyword = !QT->isEnumeralType();
18401841
Policy.FullyQualifiedName = true;
18411842
QT.getAsStringInternal(type_name, Policy);
18421843
}

unittests/CppInterOp/FunctionReflectionTest.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1994,6 +1994,21 @@ TEST(FunctionReflectionTest, GetFunctionCallWrapper) {
19941994

19951995
auto tuple_tuple_callable = Cpp::MakeFunctionCallable(tuple_tuple);
19961996
EXPECT_EQ(tuple_tuple_callable.getKind(), Cpp::JitCall::kGenericCall);
1997+
1998+
Interp->process(R"(
1999+
namespace EnumFunctionSameName {
2000+
enum foo { FOO = 42 };
2001+
void foo() {}
2002+
unsigned int bar(enum foo f) { return (unsigned int)f; }
2003+
}
2004+
)");
2005+
2006+
Cpp::TCppScope_t bar =
2007+
Cpp::GetNamed("bar", Cpp::GetScope("EnumFunctionSameName"));
2008+
EXPECT_TRUE(bar);
2009+
2010+
auto bar_callable = Cpp::MakeFunctionCallable(bar);
2011+
EXPECT_EQ(bar_callable.getKind(), Cpp::JitCall::kGenericCall);
19972012
}
19982013

19992014
TEST(FunctionReflectionTest, IsConstMethod) {

0 commit comments

Comments
 (0)