mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 20:20:10 +01:00
Adds a unit test, and some smaller edits: - Remove the `=` when defining names, in order to change `}` placement by clang-format on uses. - context: https://github.com/carbon-language/carbon-lang/pull/6053#discussion_r2343423178 - I believe with `EnumBase` that keeping the `=` had been a deliberate choice, so this PR is intended to confirm that removing it is okay. - Delete `EnumMaskBase::name` - context: https://github.com/carbon-language/carbon-lang/pull/6053#discussion_r2344233707 - We can't just do nothing because `EnumBase::name` uses indexing that's incompatible with `EnumMaskBase`. - Some small comment cleanups. - Tests don't need to be in the `Carbon` namespace anymore, macros work fine in other namespaces, but it's still the right namespace. - Documentation on `EnumBase::name` seems to be referring to a prior structure, wherein we had a macro defining the function instead of the `Names` array. --------- Co-authored-by: Richard Smith <richard@metafoo.co.uk>
33 lines
1.0 KiB
C++
33 lines
1.0 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
|
|
|
|
#include "toolchain/sem_ir/inst_kind.h"
|
|
|
|
#include "toolchain/sem_ir/typed_insts.h"
|
|
|
|
namespace Carbon::SemIR {
|
|
|
|
CARBON_DEFINE_ENUM_CLASS_NAMES(InstKind) {
|
|
#define CARBON_SEM_IR_INST_KIND(Name) CARBON_ENUM_CLASS_NAME_STRING(Name)
|
|
#include "toolchain/sem_ir/inst_kind.def"
|
|
};
|
|
|
|
auto InstKind::definition_info(InstKind inst_kind) -> const DefinitionInfo& {
|
|
static constexpr InstKind::DefinitionInfo DefinitionInfos[] = {
|
|
#define CARBON_SEM_IR_INST_KIND(Name) SemIR::Name::Kind.info_,
|
|
#include "toolchain/sem_ir/inst_kind.def"
|
|
};
|
|
return DefinitionInfos[inst_kind.AsInt()];
|
|
}
|
|
|
|
auto InstKind::has_type() const -> bool {
|
|
static constexpr bool Table[] = {
|
|
#define CARBON_SEM_IR_INST_KIND(Name) Internal::HasTypeIdMember<SemIR::Name>,
|
|
#include "toolchain/sem_ir/inst_kind.def"
|
|
};
|
|
return Table[AsInt()];
|
|
}
|
|
|
|
} // namespace Carbon::SemIR
|