@@ -17,6 +17,48 @@ using namespace TestUtils;
1717using namespace llvm ;
1818using namespace clang ;
1919
20+ TEST (ScopeReflectionTest, DemangleSymbol) {
21+ std::string code = R"(
22+ class C { public: virtual ~C() {} };
23+ namespace scope {
24+ class C { public: virtual ~C() {} };
25+ }
26+ void *get_c() { return new C; }
27+ void *get_scope_c() { return new scope::C; }
28+ )" ;
29+
30+ EXPECT_EQ (Cpp::Declare (code.c_str ()), 0 );
31+
32+ Cpp::TCppScope_t get_c = Cpp::GetNamed (" get_c" );
33+ Cpp::TCppScope_t get_scope_c = Cpp::GetNamed (" get_scope_c" );
34+ Cpp::TCppScope_t C = Cpp::GetNamed (" C" );
35+ Cpp::TCppScope_t scope_C = Cpp::GetNamed (" C" , Cpp::GetNamed (" scope" ));
36+
37+ auto get_c_callable = Cpp::MakeFunctionCallable (get_c);
38+ EXPECT_TRUE (get_c_callable.getKind () == Cpp::JitCall::kGenericCall );
39+ void * c = nullptr ;
40+ get_c_callable.Invoke (&c);
41+ EXPECT_TRUE (c);
42+
43+ auto get_scope_c_callable = Cpp::MakeFunctionCallable (get_scope_c);
44+ EXPECT_TRUE (get_scope_c_callable.getKind () == Cpp::JitCall::kGenericCall );
45+ void * scope_c = nullptr ;
46+ get_scope_c_callable.Invoke (&scope_c);
47+ EXPECT_TRUE (scope_c);
48+
49+ struct DynamicType {
50+ // Helper class to enable typeid on any address
51+ // Used in code similar to:
52+ // typeid(*(DynamicType*)void_ptr);
53+ virtual ~DynamicType () {}
54+ };
55+
56+ EXPECT_EQ (Cpp::DemangleSymbol (typeid (*(DynamicType*)c).name ()),
57+ Cpp::GetQualifiedCompleteName (C));
58+ EXPECT_EQ (Cpp::DemangleSymbol (typeid (*(DynamicType*)scope_c).name ()),
59+ Cpp::GetQualifiedCompleteName (scope_C));
60+ }
61+
2062TEST (ScopeReflectionTest, IsAggregate) {
2163 std::vector<Decl *> Decls;
2264 std::string code = R"(
0 commit comments