mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
Implement unused pattern bindings, continued (#6518)
Implementation of unused pattern bindings #2022, continued. Whereas previous PR #6460 took care of parsing, and PR #6479 prepared the stage by using _ in some test cases, this PR has the the actual implementation, using a simple dataflow analysis. --------- Co-authored-by: Burak Emir <bqe@google.com> Co-authored-by: jonmeow <jperkins@google.com>
This commit is contained in:
co-authored by
Burak Emir
jonmeow
parent
bea24a8bee
commit
fdb188ccfd
@@ -153,7 +153,8 @@ auto MakeBuiltinFunction(Context& context, SemIR::LocId loc_id,
|
||||
return_patterns_id);
|
||||
|
||||
context.full_pattern_stack().PopFullPattern();
|
||||
auto [pattern_block_id, decl_block_id] = FinishFunctionSignature(context);
|
||||
auto [pattern_block_id, decl_block_id] =
|
||||
FinishFunctionSignature(context, /*check_unused=*/false);
|
||||
|
||||
// Add the function declaration.
|
||||
// TODO: This should probably handle generics.
|
||||
@@ -409,11 +410,11 @@ auto StartFunctionSignature(Context& context) -> void {
|
||||
context.pattern_block_stack().Push();
|
||||
}
|
||||
|
||||
auto FinishFunctionSignature(Context& context)
|
||||
auto FinishFunctionSignature(Context& context, bool check_unused)
|
||||
-> FinishFunctionSignatureResult {
|
||||
auto pattern_block_id = context.pattern_block_stack().Pop();
|
||||
auto decl_block_id = context.inst_block_stack().Pop();
|
||||
context.scope_stack().Pop();
|
||||
context.scope_stack().Pop(check_unused);
|
||||
return {.pattern_block_id = pattern_block_id, .decl_block_id = decl_block_id};
|
||||
}
|
||||
|
||||
@@ -461,7 +462,7 @@ auto StartFunctionDefinition(Context& context, SemIR::InstId decl_id,
|
||||
auto FinishFunctionDefinition(Context& context, SemIR::FunctionId function_id)
|
||||
-> void {
|
||||
context.inst_block_stack().Pop();
|
||||
context.scope_stack().Pop();
|
||||
context.scope_stack().Pop(/*check_unused=*/true);
|
||||
|
||||
auto& function = context.functions().Get(function_id);
|
||||
function.body_block_ids = context.region_stack().PopRegion();
|
||||
|
||||
Reference in New Issue
Block a user