-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Lower CppOverloadSetValue #6101
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
base: trunk
Are you sure you want to change the base?
Lower CppOverloadSetValue #6101
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR says it's adding lowering, but doesn't have any changes to lowering tests. Can you please add tests that demonstrate why this is being lowered?
I added the test
While I'll look into why this is not lowered (maybe filling in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the test
toolchain/lower/testdata/interop/cpp/overloads.carbon
, with the the example from the comment, however I don't see this lowered.
Looking at that comment, I see:
import Cpp inline "void foo(); void foo(int);";
fn F() {
Cpp.foo;
}
It looks like you added a function call to that example, but I think that actually drifts away from what zygoloid was suggesting to test. In the above example, Cpp.foo
is the actual value of the statement.
You might want to look at toolchain/lower/testdata/primitives/type_values.carbon
for an example test that may also be helpful, if zygoloid's example doesn't work -- in particular putting the value on a return boundary.
toolchain/lower/handle.cpp
Outdated
|
||
auto HandleInst(FunctionContext& /*context*/, SemIR::InstId /*inst_id*/, | ||
SemIR::CppOverloadSetValue /*inst*/) -> void { | ||
// lowered as an empty struct value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// lowered as an empty struct value. | |
// Lowered as an empty struct value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
I changed the test to use the value
I also tried the following, but without any success:
As well as:
The code of If you have any further suggestions please let me know. Thanks. |
Here's a test that uses a generic to expose a value:
If you replace
So that's demonstrating that, if However, this crashes right now because you're not handling the new instructions in TypeIterator. Also, this approach assumes you implementing copying of the value ( |
Following up on comments from #5891 ( 1, 2).
Lowering
CppOverloadSetValue
as an empty struct value, usingcontext.GetLiteralAsValue()
. Also changed its constant kind toInstConstantKind::WheneverPossible
, same asCppOverloadSetType
.Part of #5915