Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/CppInterOp/CppInterOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1925,6 +1925,7 @@ void get_type_as_string(QualType QT, std::string& type_name, ASTContext& C,
Policy.SuppressElaboration = true;
Policy.SuppressTagKeyword = !QT->isEnumeralType();
Policy.FullyQualifiedName = true;
Policy.UsePreferredNames = false;
QT.getAsStringInternal(type_name, Policy);
}

Expand All @@ -1934,6 +1935,7 @@ static void GetDeclName(const clang::Decl* D, ASTContext& Context,
PrintingPolicy Policy(Context.getPrintingPolicy());
Policy.SuppressTagKeyword = true;
Policy.SuppressUnwrittenScope = true;
Policy.PrintCanonicalTypes = true;
if (const TypeDecl* TD = dyn_cast<TypeDecl>(D)) {
// This is a class, struct, or union member.
QualType QT;
Expand Down
42 changes: 42 additions & 0 deletions unittests/CppInterOp/FunctionReflectionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2112,6 +2112,48 @@ TEST(FunctionReflectionTest, GetFunctionCallWrapper) {

auto op_callable = Cpp::MakeFunctionCallable(op);
EXPECT_EQ(op_callable.getKind(), Cpp::JitCall::kGenericCall);

Cpp::Declare(R"(
enum class MyEnum { A, B, C };
template <MyEnum E>
class TemplatedEnum {};

namespace MyNameSpace {
enum class MyEnum { A, B, C };
template <MyEnum E>
class TemplatedEnum {};
}
)");

Cpp::TCppScope_t TemplatedEnum = Cpp::GetScope("TemplatedEnum");
EXPECT_TRUE(TemplatedEnum);

auto TAI_enum =
Cpp::TemplateArgInfo(Cpp::GetTypeFromScope(Cpp::GetNamed("MyEnum")), "1");
Cpp::TCppScope_t TemplatedEnum_instantiated =
Cpp::InstantiateTemplate(TemplatedEnum, &TAI_enum, 1);
EXPECT_TRUE(TemplatedEnum_instantiated);

Cpp::TCppObject_t obj = Cpp::Construct(TemplatedEnum_instantiated);
EXPECT_TRUE(obj);
Cpp::Destruct(obj, TemplatedEnum_instantiated);
obj = nullptr;

Cpp::TCppScope_t MyNameSpace_TemplatedEnum =
Cpp::GetScope("TemplatedEnum", Cpp::GetScope("MyNameSpace"));
EXPECT_TRUE(TemplatedEnum);

TAI_enum = Cpp::TemplateArgInfo(Cpp::GetTypeFromScope(Cpp::GetNamed(
"MyEnum", Cpp::GetScope("MyNameSpace"))),
"1");
Cpp::TCppScope_t MyNameSpace_TemplatedEnum_instantiated =
Cpp::InstantiateTemplate(MyNameSpace_TemplatedEnum, &TAI_enum, 1);
EXPECT_TRUE(TemplatedEnum_instantiated);

obj = Cpp::Construct(MyNameSpace_TemplatedEnum_instantiated);
EXPECT_TRUE(obj);
Cpp::Destruct(obj, MyNameSpace_TemplatedEnum_instantiated);
obj = nullptr;
}

TEST(FunctionReflectionTest, IsConstMethod) {
Expand Down
Loading