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
7 changes: 4 additions & 3 deletions lib/CppInterOp/CppInterOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,7 @@ BestOverloadFunctionMatch(const std::vector<TCppFunction_t>& candidates,
for (auto i : arg_types) {
QualType Type = QualType::getFromOpaquePtr(i.m_Type);
ExprValueKind ExprKind = ExprValueKind::VK_PRValue;
if (Type->isReferenceType())
if (Type->isLValueReferenceType())
ExprKind = ExprValueKind::VK_LValue;

new (&Exprs[idx]) OpaqueValueExpr(SourceLocation::getFromRawEncoding(1),
Expand Down Expand Up @@ -1993,8 +1993,9 @@ void make_narg_call(const FunctionDecl* FD, const std::string& return_type,
bool op_flag = !FD->isOverloadedOperator() ||
FD->getOverloadedOperator() == clang::OO_Call;

bool ShouldCastFunction =
!isa<CXXMethodDecl>(FD) && N == FD->getNumParams() && op_flag;
bool ShouldCastFunction = !isa<CXXMethodDecl>(FD) &&
N == FD->getNumParams() && op_flag &&
!FD->isTemplateInstantiation();
if (ShouldCastFunction) {
callbuf << "(";
callbuf << "(";
Expand Down
20 changes: 20 additions & 0 deletions unittests/CppInterOp/FunctionReflectionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1836,6 +1836,26 @@ TEST(FunctionReflectionTest, GetFunctionCallWrapper) {
auto fn_callable = Cpp::MakeFunctionCallable(fn);
EXPECT_EQ(fn_callable.getKind(), Cpp::JitCall::kGenericCall);

Interp->process(R"(
template <typename T>
bool call_move(T&& t) {
return true;
}
)");

unresolved_candidate_methods.clear();
Cpp::GetClassTemplatedMethods("call_move", Cpp::GetGlobalScope(),
unresolved_candidate_methods);
EXPECT_EQ(unresolved_candidate_methods.size(), 1);

Cpp::TCppScope_t call_move = Cpp::BestOverloadFunctionMatch(
unresolved_candidate_methods, {},
{Cpp::GetReferencedType(Cpp::GetType("int"), true)});
EXPECT_TRUE(call_move);

auto call_move_callable = Cpp::MakeFunctionCallable(call_move);
EXPECT_EQ(call_move_callable.getKind(), Cpp::JitCall::kGenericCall);

// instantiation in host, no template function body
Interp->process("template<typename T> T instantiation_in_host();");

Expand Down
Loading