Files
carbon-lang/toolchain/check/struct.h
oli-ej c6b54b57e2 Add check support for struct patterns (#7876)
Implements check and pattern matching support for struct patterns.

This PR implements complete patterns, and leaves `_` field handling for
future work.
2026-10-30 21:03:16 +00:00

37 lines
1.3 KiB
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_STRUCT_H_
#define CARBON_TOOLCHAIN_CHECK_STRUCT_H_
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
#include "toolchain/check/context.h"
#include "toolchain/parse/node_ids.h"
#include "toolchain/sem_ir/struct_type_field.h"
namespace Carbon::Check {
// Struct kinds, for diagnostics. Converted to an int for a format select.
enum class StructKind : uint8_t {
StructLiteral = 0,
StructTypeLiteral = 1,
StructPattern = 2
};
// Pops the names of each field from the stack. These will have been left while
// handling struct fields.
auto PopStructFieldNameNodes(Context& context, size_t field_count)
-> llvm::SmallVector<Parse::NodeId>;
// Diagnoses and returns true if there's a duplicate name.
auto DiagnoseDuplicateNames(Context& context,
llvm::ArrayRef<Parse::NodeId> field_name_nodes,
llvm::ArrayRef<SemIR::StructTypeField> fields,
StructKind struct_kind_for_diagnostic) -> bool;
} // namespace Carbon::Check
#endif // CARBON_TOOLCHAIN_CHECK_STRUCT_H_