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
13 changes: 8 additions & 5 deletions include/CppInterOp/CppInterOp.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ inline QualKind operator|(QualKind a, QualKind b) {
static_cast<unsigned char>(b));
}

enum class ValueKind : std::uint8_t {
None,
LValue,
RValue,
};

/// A class modeling function calls for functions produced by the interpreter
/// in compiled code. It provides an information if we are calling a standard
/// function, constructor or destructor.
Expand Down Expand Up @@ -615,11 +621,8 @@ CPPINTEROP_API TCppType_t GetPointeeType(TCppType_t type);
/// Checks if type is a reference
CPPINTEROP_API bool IsReferenceType(TCppType_t type);

/// Checks if type is a LValue reference
CPPINTEROP_API bool IsLValueReferenceType(TCppType_t type);

/// Checks if type is a LValue reference
CPPINTEROP_API bool IsRValueReferenceType(TCppType_t type);
/// Get if lvalue or rvalue reference
CPPINTEROP_API ValueKind GetValueKind(TCppType_t type);

/// Get the type that the reference refers to
CPPINTEROP_API TCppType_t GetNonReferenceType(TCppType_t type);
Expand Down
13 changes: 6 additions & 7 deletions lib/CppInterOp/CppInterOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1696,14 +1696,13 @@ bool IsReferenceType(TCppType_t type) {
return QT->isReferenceType();
}

bool IsLValueReferenceType(TCppType_t type) {
ValueKind GetValueKind(TCppType_t type) {
QualType QT = QualType::getFromOpaquePtr(type);
return QT->isLValueReferenceType();
}

bool IsRValueReferenceType(TCppType_t type) {
QualType QT = QualType::getFromOpaquePtr(type);
return QT->isRValueReferenceType();
if (QT->isRValueReferenceType())
return ValueKind::RValue;
if (QT->isLValueReferenceType())
return ValueKind::LValue;
return ValueKind::None;
}

TCppType_t GetPointerType(TCppType_t type) {
Expand Down
10 changes: 7 additions & 3 deletions unittests/CppInterOp/VariableReflectionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,11 +723,15 @@ TYPED_TEST(CppInterOpTest, VariableReflectionTestIs_Get_Reference) {

EXPECT_FALSE(Cpp::GetNonReferenceType(Cpp::GetVariableType(Decls[5])));

EXPECT_TRUE(Cpp::IsLValueReferenceType(Cpp::GetVariableType(Decls[2])));
EXPECT_EQ(Cpp::GetValueKind(Cpp::GetVariableType(Decls[2])),
Cpp::ValueKind::LValue);
EXPECT_EQ(Cpp::GetReferencedType(Cpp::GetVariableType(Decls[1])),
Cpp::GetVariableType(Decls[2]));
EXPECT_TRUE(Cpp::IsRValueReferenceType(
Cpp::GetReferencedType(Cpp::GetVariableType(Decls[1]), true)));
EXPECT_EQ(Cpp::GetValueKind(
Cpp::GetReferencedType(Cpp::GetVariableType(Decls[1]), true)),
Cpp::ValueKind::RValue);
EXPECT_EQ(Cpp::GetValueKind(Cpp::GetVariableType(Decls[1])),
Cpp::ValueKind::None);
}

TYPED_TEST(CppInterOpTest, VariableReflectionTestGetPointerType) {
Expand Down
Loading