File tree Expand file tree Collapse file tree 3 files changed +47
-3
lines changed Expand file tree Collapse file tree 3 files changed +47
-3
lines changed Original file line number Diff line number Diff line change @@ -544,11 +544,18 @@ CPPINTEROP_API bool IsReferenceType(TCppType_t type);
544
544
// / Checks if type is a LValue reference
545
545
CPPINTEROP_API bool IsLValueReferenceType (TCppType_t type);
546
546
547
+ // / Checks if type is a LValue reference
548
+ CPPINTEROP_API bool IsRValueReferenceType (TCppType_t type);
549
+
547
550
// / Get the type that the reference refers to
548
551
CPPINTEROP_API TCppType_t GetNonReferenceType (TCppType_t type);
549
552
550
- // / Get lvalue referenced type
551
- CPPINTEROP_API TCppType_t GetReferencedType (TCppType_t type);
553
+ // / Get lvalue referenced type, or rvalue if rvalue is true
554
+ CPPINTEROP_API TCppType_t GetReferencedType (TCppType_t type,
555
+ bool rvalue = false );
556
+
557
+ // / Get the pointer to type
558
+ CPPINTEROP_API TCppType_t GetPointerType (TCppType_t type);
552
559
553
560
// / Gets the pure, Underlying Type (as opposed to the Using Type).
554
561
CPPINTEROP_API TCppType_t GetUnderlyingType (TCppType_t type);
Original file line number Diff line number Diff line change @@ -1615,8 +1615,20 @@ bool IsLValueReferenceType(TCppType_t type) {
1615
1615
return QT->isLValueReferenceType ();
1616
1616
}
1617
1617
1618
- TCppType_t GetReferencedType (TCppType_t type) {
1618
+ bool IsRValueReferenceType (TCppType_t type) {
1619
1619
QualType QT = QualType::getFromOpaquePtr (type);
1620
+ return QT->isRValueReferenceType ();
1621
+ }
1622
+
1623
+ TCppType_t GetPointerType (TCppType_t type) {
1624
+ QualType QT = QualType::getFromOpaquePtr (type);
1625
+ return getASTContext ().getPointerType (QT).getAsOpaquePtr ();
1626
+ }
1627
+
1628
+ TCppType_t GetReferencedType (TCppType_t type, bool rvalue) {
1629
+ QualType QT = QualType::getFromOpaquePtr (type);
1630
+ if (rvalue)
1631
+ return getASTContext ().getRValueReferenceType (QT).getAsOpaquePtr ();
1620
1632
return getASTContext ().getLValueReferenceType (QT).getAsOpaquePtr ();
1621
1633
}
1622
1634
Original file line number Diff line number Diff line change @@ -681,4 +681,29 @@ TEST(VariableReflectionTest, Is_Get_Reference) {
681
681
EXPECT_TRUE (Cpp::IsLValueReferenceType (Cpp::GetVariableType (Decls[2 ])));
682
682
EXPECT_EQ (Cpp::GetReferencedType (Cpp::GetVariableType (Decls[1 ])),
683
683
Cpp::GetVariableType (Decls[2 ]));
684
+ EXPECT_TRUE (Cpp::IsRValueReferenceType (
685
+ Cpp::GetReferencedType (Cpp::GetVariableType (Decls[1 ]), true )));
686
+ }
687
+
688
+ TEST (VariableReflectionTest, GetPointerType) {
689
+ Cpp::CreateInterpreter ();
690
+ std::vector<Decl*> Decls;
691
+ std::string code = R"(
692
+ class A {};
693
+ int a;
694
+ int *b = &a;
695
+ double c;
696
+ double *d = &c;
697
+ A e;
698
+ A *f = &e;
699
+ )" ;
700
+
701
+ GetAllTopLevelDecls (code, Decls);
702
+
703
+ EXPECT_EQ (Cpp::GetPointerType (Cpp::GetVariableType (Decls[1 ])),
704
+ Cpp::GetVariableType (Decls[2 ]));
705
+ EXPECT_EQ (Cpp::GetPointerType (Cpp::GetVariableType (Decls[3 ])),
706
+ Cpp::GetVariableType (Decls[4 ]));
707
+ EXPECT_EQ (Cpp::GetPointerType (Cpp::GetVariableType (Decls[5 ])),
708
+ Cpp::GetVariableType (Decls[6 ]));
684
709
}
You can’t perform that action at this time.
0 commit comments