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.
127 lines
6.5 KiB
Plaintext
127 lines
6.5 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/pointer/arrow.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/pointer/arrow.carbon
|
|
|
|
class C {
|
|
fn Member[self: Self]();
|
|
var field: C*;
|
|
}
|
|
|
|
fn Foo(ptr: C*) {
|
|
(*ptr).Member();
|
|
ptr->Member();
|
|
|
|
(*ptr).field;
|
|
ptr->field;
|
|
|
|
ptr->field->field;
|
|
}
|
|
|
|
// CHECK:STDOUT: --- arrow.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %C: type = class_type @C [template]
|
|
// CHECK:STDOUT: %Member.type: type = fn_type @Member [template]
|
|
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
|
|
// CHECK:STDOUT: %Member: %Member.type = struct_value () [template]
|
|
// CHECK:STDOUT: %ptr.019: type = ptr_type %C [template]
|
|
// CHECK:STDOUT: %C.elem: type = unbound_element_type %C, %ptr.019 [template]
|
|
// CHECK:STDOUT: %struct_type.field: type = struct_type {.field: %ptr.019} [template]
|
|
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.field [template]
|
|
// CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template]
|
|
// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template]
|
|
// 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: .C = %C.decl
|
|
// CHECK:STDOUT: .Foo = %Foo.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Core.import = import Core
|
|
// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
|
|
// CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] {
|
|
// CHECK:STDOUT: %ptr.patt: %ptr.019 = binding_pattern ptr
|
|
// CHECK:STDOUT: %ptr.param_patt: %ptr.019 = value_param_pattern %ptr.patt, runtime_param0
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %ptr.param: %ptr.019 = value_param runtime_param0
|
|
// CHECK:STDOUT: %.loc16: type = splice_block %ptr.loc16_14 [template = constants.%ptr.019] {
|
|
// CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
|
|
// CHECK:STDOUT: %ptr.loc16_14: type = ptr_type %C [template = constants.%ptr.019]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %ptr.loc16_8: %ptr.019 = bind_name ptr, %ptr.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class @C {
|
|
// CHECK:STDOUT: %Member.decl: %Member.type = fn_decl @Member [template = constants.%Member] {
|
|
// CHECK:STDOUT: %self.patt: %C = binding_pattern self
|
|
// CHECK:STDOUT: %self.param_patt: %C = value_param_pattern %self.patt, runtime_param0
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %self.param: %C = value_param runtime_param0
|
|
// CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [template = constants.%C]
|
|
// CHECK:STDOUT: %self: %C = bind_name self, %self.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %.loc13_12: %C.elem = field_decl field, element0 [template]
|
|
// CHECK:STDOUT: name_binding_decl {
|
|
// CHECK:STDOUT: %.loc13_3: %C.elem = var_pattern %.loc13_12
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %.var: ref %C.elem = var <none>
|
|
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.field [template = constants.%complete_type]
|
|
// CHECK:STDOUT: complete_type_witness = %complete_type
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = constants.%C
|
|
// CHECK:STDOUT: .Member = %Member.decl
|
|
// CHECK:STDOUT: .field = %.loc13_12
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Member[%self.param_patt: %C]();
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Foo(%ptr.param_patt: %ptr.019) {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %ptr.ref.loc17: %ptr.019 = name_ref ptr, %ptr.loc16_8
|
|
// CHECK:STDOUT: %.loc17_4.1: ref %C = deref %ptr.ref.loc17
|
|
// CHECK:STDOUT: %Member.ref.loc17: %Member.type = name_ref Member, @C.%Member.decl [template = constants.%Member]
|
|
// CHECK:STDOUT: %Member.bound.loc17: <bound method> = bound_method %.loc17_4.1, %Member.ref.loc17
|
|
// CHECK:STDOUT: %.loc17_4.2: %C = bind_value %.loc17_4.1
|
|
// CHECK:STDOUT: %Member.call.loc17: init %empty_tuple.type = call %Member.bound.loc17(%.loc17_4.2)
|
|
// CHECK:STDOUT: %ptr.ref.loc18: %ptr.019 = name_ref ptr, %ptr.loc16_8
|
|
// CHECK:STDOUT: %.loc18_6.1: ref %C = deref %ptr.ref.loc18
|
|
// CHECK:STDOUT: %Member.ref.loc18: %Member.type = name_ref Member, @C.%Member.decl [template = constants.%Member]
|
|
// CHECK:STDOUT: %Member.bound.loc18: <bound method> = bound_method %.loc18_6.1, %Member.ref.loc18
|
|
// CHECK:STDOUT: %.loc18_6.2: %C = bind_value %.loc18_6.1
|
|
// CHECK:STDOUT: %Member.call.loc18: init %empty_tuple.type = call %Member.bound.loc18(%.loc18_6.2)
|
|
// CHECK:STDOUT: %ptr.ref.loc20: %ptr.019 = name_ref ptr, %ptr.loc16_8
|
|
// CHECK:STDOUT: %.loc20_4: ref %C = deref %ptr.ref.loc20
|
|
// CHECK:STDOUT: %field.ref.loc20: %C.elem = name_ref field, @C.%.loc13_12 [template = @C.%.loc13_12]
|
|
// CHECK:STDOUT: %.loc20_9: ref %ptr.019 = class_element_access %.loc20_4, element0
|
|
// CHECK:STDOUT: %ptr.ref.loc21: %ptr.019 = name_ref ptr, %ptr.loc16_8
|
|
// CHECK:STDOUT: %.loc21_6.1: ref %C = deref %ptr.ref.loc21
|
|
// CHECK:STDOUT: %field.ref.loc21: %C.elem = name_ref field, @C.%.loc13_12 [template = @C.%.loc13_12]
|
|
// CHECK:STDOUT: %.loc21_6.2: ref %ptr.019 = class_element_access %.loc21_6.1, element0
|
|
// CHECK:STDOUT: %ptr.ref.loc23: %ptr.019 = name_ref ptr, %ptr.loc16_8
|
|
// CHECK:STDOUT: %.loc23_6.1: ref %C = deref %ptr.ref.loc23
|
|
// CHECK:STDOUT: %field.ref.loc23_6: %C.elem = name_ref field, @C.%.loc13_12 [template = @C.%.loc13_12]
|
|
// CHECK:STDOUT: %.loc23_6.2: ref %ptr.019 = class_element_access %.loc23_6.1, element0
|
|
// CHECK:STDOUT: %.loc23_6.3: %ptr.019 = bind_value %.loc23_6.2
|
|
// CHECK:STDOUT: %.loc23_13.1: ref %C = deref %.loc23_6.3
|
|
// CHECK:STDOUT: %field.ref.loc23_13: %C.elem = name_ref field, @C.%.loc13_12 [template = @C.%.loc13_12]
|
|
// CHECK:STDOUT: %.loc23_13.2: ref %ptr.019 = class_element_access %.loc23_13.1, element0
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|