Skip to content

Commit 6ea4209

Browse files
Vipul-Cariappavgvassilev
authored andcommitted
add test & comment
1 parent 34f2dde commit 6ea4209

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

lib/Interpreter/CppInterOp.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,6 +1964,8 @@ namespace Cpp {
19641964
// even when we supply the object parameter. Therefore we only use it in
19651965
// cases where we know it works and set this variable to true when we do.
19661966

1967+
// true if not a overloaded operators or the overloaded operator is call
1968+
// operator
19671969
bool op_flag = !FD->isOverloadedOperator() ||
19681970
FD->getOverloadedOperator() == clang::OO_Call;
19691971

unittests/CppInterOp/FunctionReflectionTest.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,6 +1684,36 @@ TEST(FunctionReflectionTest, GetFunctionCallWrapper) {
16841684
bool boolean = false;
16851685
FCI_op.Invoke((void*)&boolean, {args, /*args_size=*/1}, object);
16861686
EXPECT_TRUE(boolean);
1687+
1688+
Interp->process("#include <chrono>");
1689+
Cpp::TCppScope_t chrono = Cpp::GetNamed("chrono", Cpp::GetNamed("std"));
1690+
EXPECT_TRUE(chrono);
1691+
1692+
Cpp::TCppScope_t seconds = Cpp::GetNamed("seconds", chrono);
1693+
EXPECT_TRUE(seconds);
1694+
1695+
operators.clear();
1696+
Cpp::GetOperator(chrono, Cpp::OP_Plus, operators);
1697+
EXPECT_TRUE(operators.size());
1698+
1699+
Cpp::TCppType_t seconds_type = Cpp::GetTypeFromScope(seconds);
1700+
EXPECT_TRUE(seconds_type);
1701+
1702+
Cpp::TCppScope_t system_clock = Cpp::GetNamed("system_clock", chrono);
1703+
EXPECT_TRUE(system_clock);
1704+
1705+
Cpp::TCppScope_t now_fn = Cpp::GetNamed("now", system_clock);
1706+
EXPECT_TRUE(now_fn);
1707+
1708+
Cpp::TCppType_t time_point_type = Cpp::GetFunctionReturnType(now_fn);
1709+
EXPECT_TRUE(time_point_type);
1710+
1711+
Cpp::TCppFunction_t chrono_op_fn = Cpp::BestOverloadFunctionMatch(
1712+
operators, {}, {time_point_type, seconds_type});
1713+
EXPECT_TRUE(chrono_op_fn);
1714+
1715+
auto chrono_op_fn_callable = Cpp::MakeFunctionCallable(chrono_op_fn);
1716+
EXPECT_EQ(chrono_op_fn_callable.getKind(), Cpp::JitCall::kGenericCall);
16871717
}
16881718

16891719
TEST(FunctionReflectionTest, IsConstMethod) {

0 commit comments

Comments
 (0)