Skip to content

fix JitCall codegen for function with lambda as return value #678

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Vipul-Cariappa
Copy link
Collaborator

Description

Fixes # (issue)

Helps fix a test in cppyy

Type of change

Please tick all options which are relevant.

  • Bug fix
  • New feature
  • Requires documentation updates

Testing

Checklist

  • I have read the contribution guide recently

Copy link

codecov bot commented Jul 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.71%. Comparing base (515c1c8) to head (1a8c719).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #678      +/-   ##
==========================================
+ Coverage   79.61%   79.71%   +0.09%     
==========================================
  Files           9        9              
  Lines        3925     3944      +19     
==========================================
+ Hits         3125     3144      +19     
  Misses        800      800              
Files with missing lines Coverage Δ
include/CppInterOp/CppInterOp.h 95.55% <ø> (ø)
lib/CppInterOp/CppInterOp.cpp 87.85% <100.00%> (+0.10%) ⬆️
Files with missing lines Coverage Δ
include/CppInterOp/CppInterOp.h 95.55% <ø> (ø)
lib/CppInterOp/CppInterOp.cpp 87.85% <100.00%> (+0.10%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

DeclarationName DFunction = &getASTContext().Idents.get("function");
auto result = getSema().getStdNamespace()->lookup(DFunction);
if (result.empty())
Cpp::Declare("#include <functional>");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel uncomfortable including and now . I am not sure how else to solve this but is there some way to write our own minimal std::function-like class that does what we need it to?

bool IsLambdaClass(TCppType_t type) {
QualType QT = QualType::getFromOpaquePtr(type);
if (auto* CXXRD = QT->getAsCXXRecordDecl()) {
return CXXRD->isLambda();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI isLambdaCallOperator in clang.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isLambdaCallOperator takes a CXXMethodDecl, but we are using QualType to check here.
Also, we are not checking if the function is the lambda call operator; instead, we are checking if the given class is a lambda class.

Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

}
if (auto* CXXRD = QT->getAsCXXRecordDecl()) {
if (CXXRD->isLambda()) {
static bool flag = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No statics anymore. We have a stack of interpreters. Maybe we feed that as part of Cpp::CreateIntepreter...

Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants