mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
High level, replacing `Id::Invalid` with `Id::None` and `Id::is_valid` with `Id::has_value` for clarity, as discussed [here](https://discord.com/channels/655572317891461132/655578254970716160/1331664574545395794). The `IntId` refactoring is needed together with `AnyIdBase` because it's also used with `ValueStore`. Note, trying to be careful not to rewrite `EnumBase::InvalidIndex`, or `is_valid` in general (e.g., `IdKind::is_valid`). I've tried to sequence commits here: 1. Automatic replacements: - `((?:Id|Index)(?: |::|\(|Base(?:\(|::)))Invalid((?:Index)?\W)` -> `$1None$2` - `<invalid>` -> `<none>` - `InvalidNodeId` -> `NoneNodeId` - `/\*invalid\*/` -> `/*none*/` - `id((?:_|\(\))(?:\.|->))is_valid` -> `id$1has_value` 2. Manual edits: - In `int.h` and `int_test.cpp` - `IntT` has `is_value`, which I'm renaming to `is_embedded_value`. - Manual edits to comments in this file. - `AnyIdBase` and `IdBase` - Declaration of `is_valid` -> `has_value`, `InvalidIndex` -> `NoneIndex`. - In `ids.h` and `ids.cpp` - `is_valid` -> `has_value` - `// An explicitly invalid ID.` -> `// An ID with no value.`; similar for index - Various math on `InvalidIndex` -> `NoneIndex` - Various mentions of "valid" in comments - In `value_store.h`, for `IdT::Invalid`, plus one comment - In `impl.h` and `tokenized_buffer.h`, we had different initialization of `::None` values (versus `ids.h` syntax) that I fixed manually. - Spot checks to compile - Particularly where `is_valid` replacements didn't catch spots due to different naming. 3. Autoupdate tests 4. verbose.carbon (NOAUTOUPDATE) 5. Comment spot checks Note there are probably other mentions of "Invalid" that should be swept up, but I'd like to argue for merging and separating out remaining cleanup since this is so sweeping (and likely to hit merge conflicts from churn). We'll probably have lingering mentions of "invalid" for a bit regardless, just because there are uses of "invalid" in non-Id APIs.
87 lines
4.9 KiB
Plaintext
87 lines
4.9 KiB
Plaintext
// 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
|
|
//
|
|
// AUTOUPDATE
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/array/generic_empty.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/generic_empty.carbon
|
|
|
|
fn G(T:! type) {
|
|
// We can initialize this without knowing T.
|
|
var arr: [T; 0] = ();
|
|
}
|
|
|
|
// CHECK:STDOUT: --- generic_empty.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
|
|
// CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
|
|
// CHECK:STDOUT: %G.type: type = fn_type @G [template]
|
|
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
|
|
// CHECK:STDOUT: %G: %G.type = struct_value () [template]
|
|
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template]
|
|
// CHECK:STDOUT: %array_type: type = array_type %int_0, %T [symbolic]
|
|
// CHECK:STDOUT: %require_complete: <witness> = require_complete_type %array_type [symbolic]
|
|
// CHECK:STDOUT: %array: %array_type = tuple_value () [symbolic]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: imports {
|
|
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
|
|
// CHECK:STDOUT: import Core//prelude
|
|
// CHECK:STDOUT: import Core//prelude/...
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
|
// CHECK:STDOUT: .Core = imports.%Core
|
|
// CHECK:STDOUT: .G = %G.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Core.import = import Core
|
|
// CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
|
|
// CHECK:STDOUT: %T.patt.loc11_6.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc11_6.2 (constants.%T.patt)]
|
|
// CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc11_6.1, runtime_param<none> [symbolic = %T.patt.loc11_6.2 (constants.%T.patt)]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %T.param: type = value_param runtime_param<none>
|
|
// CHECK:STDOUT: %T.loc11_6.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc11_6.2 (constants.%T)]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: generic fn @G(%T.loc11_6.1: type) {
|
|
// CHECK:STDOUT: %T.loc11_6.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc11_6.2 (constants.%T)]
|
|
// CHECK:STDOUT: %T.patt.loc11_6.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc11_6.2 (constants.%T.patt)]
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !definition:
|
|
// CHECK:STDOUT: %array_type.loc13_17.2: type = array_type constants.%int_0, @G.%T.loc11_6.2 (%T) [symbolic = %array_type.loc13_17.2 (constants.%array_type)]
|
|
// CHECK:STDOUT: %require_complete: <witness> = require_complete_type @G.%array_type.loc13_17.2 (%array_type) [symbolic = %require_complete (constants.%require_complete)]
|
|
// CHECK:STDOUT: %array: @G.%array_type.loc13_17.2 (%array_type) = tuple_value () [symbolic = %array (constants.%array)]
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn(%T.param_patt: type) {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: name_binding_decl {
|
|
// CHECK:STDOUT: %arr.patt: @G.%array_type.loc13_17.2 (%array_type) = binding_pattern arr
|
|
// CHECK:STDOUT: %.loc13_3.1: @G.%array_type.loc13_17.2 (%array_type) = var_pattern %arr.patt
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %arr.var: ref @G.%array_type.loc13_17.2 (%array_type) = var arr
|
|
// CHECK:STDOUT: %.loc13_22.1: %empty_tuple.type = tuple_literal ()
|
|
// CHECK:STDOUT: %.loc13_22.2: init @G.%array_type.loc13_17.2 (%array_type) = array_init () to %arr.var [symbolic = %array (constants.%array)]
|
|
// CHECK:STDOUT: %.loc13_3.2: init @G.%array_type.loc13_17.2 (%array_type) = converted %.loc13_22.1, %.loc13_22.2 [symbolic = %array (constants.%array)]
|
|
// CHECK:STDOUT: assign %arr.var, %.loc13_3.2
|
|
// CHECK:STDOUT: %.loc13_17: type = splice_block %array_type.loc13_17.1 [symbolic = %array_type.loc13_17.2 (constants.%array_type)] {
|
|
// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc11_6.1 [symbolic = %T.loc11_6.2 (constants.%T)]
|
|
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0]
|
|
// CHECK:STDOUT: %array_type.loc13_17.1: type = array_type %int_0, %T [symbolic = %array_type.loc13_17.2 (constants.%array_type)]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %arr: ref @G.%array_type.loc13_17.2 (%array_type) = bind_name arr, %arr.var
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: specific @G(constants.%T) {
|
|
// CHECK:STDOUT: %T.loc11_6.2 => constants.%T
|
|
// CHECK:STDOUT: %T.patt.loc11_6.2 => constants.%T
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|