Skip to content

Commit a8cd00a

Browse files
add test & comment
1 parent 3380441 commit a8cd00a

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
@@ -1680,6 +1680,36 @@ TEST(FunctionReflectionTest, GetFunctionCallWrapper) {
16801680
bool boolean = false;
16811681
FCI_op.Invoke((void*)&boolean, {args, /*args_size=*/1}, object);
16821682
EXPECT_TRUE(boolean);
1683+
1684+
Interp->process("#include <chrono>");
1685+
Cpp::TCppScope_t chrono = Cpp::GetNamed("chrono", Cpp::GetNamed("std"));
1686+
EXPECT_TRUE(chrono);
1687+
1688+
Cpp::TCppScope_t seconds = Cpp::GetNamed("seconds", chrono);
1689+
EXPECT_TRUE(seconds);
1690+
1691+
operators.clear();
1692+
Cpp::GetOperator(chrono, Cpp::OP_Plus, operators);
1693+
EXPECT_TRUE(operators.size());
1694+
1695+
Cpp::TCppType_t seconds_type = Cpp::GetTypeFromScope(seconds);
1696+
EXPECT_TRUE(seconds_type);
1697+
1698+
Cpp::TCppScope_t system_clock = Cpp::GetNamed("system_clock", chrono);
1699+
EXPECT_TRUE(system_clock);
1700+
1701+
Cpp::TCppScope_t now_fn = Cpp::GetNamed("now", system_clock);
1702+
EXPECT_TRUE(now_fn);
1703+
1704+
Cpp::TCppType_t time_point_type = Cpp::GetFunctionReturnType(now_fn);
1705+
EXPECT_TRUE(time_point_type);
1706+
1707+
Cpp::TCppFunction_t chrono_op_fn = Cpp::BestOverloadFunctionMatch(
1708+
operators, {}, {time_point_type, seconds_type});
1709+
EXPECT_TRUE(chrono_op_fn);
1710+
1711+
auto chrono_op_fn_callable = Cpp::MakeFunctionCallable(chrono_op_fn);
1712+
EXPECT_EQ(chrono_op_fn_callable.getKind(), Cpp::JitCall::kGenericCall);
16831713
}
16841714

16851715
TEST(FunctionReflectionTest, IsConstMethod) {

0 commit comments

Comments
 (0)