Files
carbon-lang/toolchain/check/unused.h
T
fdb188ccfd 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>
2026-02-19 23:33:36 +00:00

24 lines
914 B
C++

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#ifndef CARBON_TOOLCHAIN_CHECK_UNUSED_H_
#define CARBON_TOOLCHAIN_CHECK_UNUSED_H_
#include "toolchain/check/context.h"
#include "toolchain/check/scope_stack.h"
namespace Carbon::Check {
// Checks for an unused binding. We track whether a name was declared in a
// reachable position, and whether it was used (even in unreachable code), to
// decide whether to warn. If a name is used in unreachable code, we don't warn
// because changing it to `_` would be a name lookup error in that unreachable
// code.
auto CheckUnusedBinding(Context& context, SemIR::NameId name_id,
const LexicalLookup::Result& result) -> void;
} // namespace Carbon::Check
#endif // CARBON_TOOLCHAIN_CHECK_UNUSED_H_