-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fix C++ function params and return values printed in SemIR #5468
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?
Fix C++ function params and return values printed in SemIR #5468
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.
Can we extract more logic from HandleAnyBindingPattern()
so we can reuse it instead of doing it here, so we can more easily maintain this in case the logic changes?
// Marks the start a region of insts, needed for the type | ||
// expression created later with the call of EndSubpatternAsExpr. |
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.
// Marks the start a region of insts, needed for the type | |
// expression created later with the call of EndSubpatternAsExpr. | |
// Mark the start of a region of insts, needed for the type expression | |
// created later with the call of `EndSubpatternAsExpr()`. |
|
||
// TODO: Fix this once templates are supported. | ||
bool is_template = false; | ||
// TODO: Fix this once templates are supported. |
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.
// TODO: Fix this once templates are supported. | |
// TODO: Fix this once generics are supported. |
context.pattern_block_stack().Pop(); | ||
return SemIR::ErrorInst::InstId; | ||
} | ||
auto return_slot_pattern_id = GetReturnType(context, loc_id, clang_decl); | ||
auto pattern_block_id = context.pattern_block_stack().Pop(); |
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.
If you can't rearrange the code so that Pop()
is called in one place, consider using llvm::make_scope_exit()
to make sure we call Pop()
.
if (SemIR::ErrorInst::InstId == return_slot_pattern_id) { | ||
return SemIR::ErrorInst::InstId; | ||
} | ||
|
||
context.inst_block_stack().Push(); |
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 think you need to move this up, at least above GetReturnType
, but preferably to the beginning of the function, because this block needs to hold all the non-pattern insts emitted as part of the function declaration. Right now the type insts for the return type are getting lost.
(Those insts don't really belong here, but we don't have a better place for them yet, so this code should be consistent with the native-Carbon code).
Fix
pattern_block_id
andcall_params_id
for C++ function decl import, to get the correct SemIR printout for the C++ functions i.e.Closes #5449