mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 20:20:10 +01:00
Per #7737 we move the default value `InstId` storage from a block in the `SemIR::Function` data structure to a `SemIR::File` scoped `ValueStore`. Moves the default value consistency checking to the general merge argument pattern matching logic, which changes the error message issued to the generic one.
46 lines
1.5 KiB
C++
46 lines
1.5 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_SEM_IR_DEFAULT_VALUE_H_
|
|
#define CARBON_TOOLCHAIN_SEM_IR_DEFAULT_VALUE_H_
|
|
|
|
#include "toolchain/base/value_store.h"
|
|
#include "toolchain/sem_ir/ids.h"
|
|
|
|
namespace Carbon::SemIR {
|
|
|
|
// Information about a default value for a pattern, such as default values for
|
|
// function parameters.
|
|
struct DefaultValue : public Printable<DefaultValue> {
|
|
auto Print(llvm::raw_ostream& out) const -> void {
|
|
out << "{raw_id: " << raw_id << ", value_id: " << value_id
|
|
<< ", is_unspecified: " << is_unspecified << "}";
|
|
}
|
|
|
|
// The instruction specifying the default value as specified by the developer,
|
|
// before conversion to the pattern scrutinee type is applied.
|
|
InstId raw_id;
|
|
|
|
// The instruction specifying the default value in the same type as the
|
|
// scrutinee type.
|
|
InstId value_id;
|
|
|
|
// Whether the user left this default value unspecified. The `value_id` will
|
|
// be `None` but the `raw_id` will contain the `UnspecifiedValue` instruction
|
|
// for use in diagnostics if needed.
|
|
bool is_unspecified;
|
|
};
|
|
|
|
using DefaultValueStore =
|
|
ValueStore<DefaultValueId, DefaultValue, Tag<SemIR::CheckIRId>>;
|
|
|
|
} // namespace Carbon::SemIR
|
|
|
|
namespace Carbon {
|
|
extern template class ValueStore<SemIR::DefaultValueId, SemIR::DefaultValue,
|
|
Tag<SemIR::CheckIRId>>;
|
|
}
|
|
|
|
#endif // CARBON_TOOLCHAIN_SEM_IR_DEFAULT_VALUE_H_
|