mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 22:02:52 +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.
179 lines
8.7 KiB
Plaintext
179 lines
8.7 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/namespace/imported.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/namespace/imported.carbon
|
|
|
|
// --- implicit.carbon
|
|
|
|
package Implicit;
|
|
|
|
namespace NS;
|
|
namespace NS.ChildNS;
|
|
|
|
fn NS.A();
|
|
fn NS.ChildNS.B();
|
|
|
|
// --- implicit.impl.carbon
|
|
|
|
impl package Implicit;
|
|
|
|
var a: () = NS.A();
|
|
var b: () = NS.ChildNS.B();
|
|
|
|
var package_a: () = package.NS.A();
|
|
var package_b: () = package.NS.ChildNS.B();
|
|
|
|
// CHECK:STDOUT: --- implicit.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %A.type: type = fn_type @A [template]
|
|
// CHECK:STDOUT: %A: %A.type = struct_value () [template]
|
|
// CHECK:STDOUT: %B.type: type = fn_type @B [template]
|
|
// CHECK:STDOUT: %B: %B.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: .NS = %NS
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Core.import = import Core
|
|
// CHECK:STDOUT: %NS: <namespace> = namespace [template] {
|
|
// CHECK:STDOUT: .ChildNS = %ChildNS
|
|
// CHECK:STDOUT: .A = %A.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %ChildNS: <namespace> = namespace [template] {
|
|
// CHECK:STDOUT: .B = %B.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} {}
|
|
// CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] {} {}
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @A();
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @B();
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: --- implicit.impl.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
|
|
// CHECK:STDOUT: %A.type: type = fn_type @A [template]
|
|
// CHECK:STDOUT: %A: %A.type = struct_value () [template]
|
|
// CHECK:STDOUT: %B.type: type = fn_type @B [template]
|
|
// CHECK:STDOUT: %B: %B.type = struct_value () [template]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: imports {
|
|
// CHECK:STDOUT: %Implicit.NS: <namespace> = import_ref Implicit//default, NS, loaded
|
|
// CHECK:STDOUT: %NS: <namespace> = namespace %Implicit.NS, [template] {
|
|
// CHECK:STDOUT: .A = %Implicit.A
|
|
// CHECK:STDOUT: .ChildNS = %ChildNS
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Implicit.A: %A.type = import_ref Implicit//default, A, loaded [template = constants.%A]
|
|
// CHECK:STDOUT: %Implicit.ChildNS: <namespace> = import_ref Implicit//default, ChildNS, loaded
|
|
// CHECK:STDOUT: %ChildNS: <namespace> = namespace %Implicit.ChildNS, [template] {
|
|
// CHECK:STDOUT: .B = %Implicit.B
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Implicit.B: %B.type = import_ref Implicit//default, B, loaded [template = constants.%B]
|
|
// 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: .NS = imports.%NS
|
|
// CHECK:STDOUT: .Core = imports.%Core
|
|
// CHECK:STDOUT: .a = %a
|
|
// CHECK:STDOUT: .b = %b
|
|
// CHECK:STDOUT: .package_a = %package_a
|
|
// CHECK:STDOUT: .package_b = %package_b
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Implicit.import = import Implicit
|
|
// CHECK:STDOUT: %default.import = import <none>
|
|
// CHECK:STDOUT: %Core.import = import Core
|
|
// CHECK:STDOUT: name_binding_decl {
|
|
// CHECK:STDOUT: %a.patt: %empty_tuple.type = binding_pattern a
|
|
// CHECK:STDOUT: %.loc4_1: %empty_tuple.type = var_pattern %a.patt
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %a.var: ref %empty_tuple.type = var a
|
|
// CHECK:STDOUT: %.loc4_9.1: type = splice_block %.loc4_9.3 [template = constants.%empty_tuple.type] {
|
|
// CHECK:STDOUT: %.loc4_9.2: %empty_tuple.type = tuple_literal ()
|
|
// CHECK:STDOUT: %.loc4_9.3: type = converted %.loc4_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var
|
|
// CHECK:STDOUT: name_binding_decl {
|
|
// CHECK:STDOUT: %b.patt: %empty_tuple.type = binding_pattern b
|
|
// CHECK:STDOUT: %.loc5_1: %empty_tuple.type = var_pattern %b.patt
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %b.var: ref %empty_tuple.type = var b
|
|
// CHECK:STDOUT: %.loc5_9.1: type = splice_block %.loc5_9.3 [template = constants.%empty_tuple.type] {
|
|
// CHECK:STDOUT: %.loc5_9.2: %empty_tuple.type = tuple_literal ()
|
|
// CHECK:STDOUT: %.loc5_9.3: type = converted %.loc5_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %b: ref %empty_tuple.type = bind_name b, %b.var
|
|
// CHECK:STDOUT: name_binding_decl {
|
|
// CHECK:STDOUT: %package_a.patt: %empty_tuple.type = binding_pattern package_a
|
|
// CHECK:STDOUT: %.loc7_1: %empty_tuple.type = var_pattern %package_a.patt
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %package_a.var: ref %empty_tuple.type = var package_a
|
|
// CHECK:STDOUT: %.loc7_17.1: type = splice_block %.loc7_17.3 [template = constants.%empty_tuple.type] {
|
|
// CHECK:STDOUT: %.loc7_17.2: %empty_tuple.type = tuple_literal ()
|
|
// CHECK:STDOUT: %.loc7_17.3: type = converted %.loc7_17.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %package_a: ref %empty_tuple.type = bind_name package_a, %package_a.var
|
|
// CHECK:STDOUT: name_binding_decl {
|
|
// CHECK:STDOUT: %package_b.patt: %empty_tuple.type = binding_pattern package_b
|
|
// CHECK:STDOUT: %.loc8_1: %empty_tuple.type = var_pattern %package_b.patt
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %package_b.var: ref %empty_tuple.type = var package_b
|
|
// CHECK:STDOUT: %.loc8_17.1: type = splice_block %.loc8_17.3 [template = constants.%empty_tuple.type] {
|
|
// CHECK:STDOUT: %.loc8_17.2: %empty_tuple.type = tuple_literal ()
|
|
// CHECK:STDOUT: %.loc8_17.3: type = converted %.loc8_17.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %package_b: ref %empty_tuple.type = bind_name package_b, %package_b.var
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @A() [from "implicit.carbon"];
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @B() [from "implicit.carbon"];
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @__global_init() {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %NS.ref.loc4: <namespace> = name_ref NS, imports.%NS [template = imports.%NS]
|
|
// CHECK:STDOUT: %A.ref.loc4: %A.type = name_ref A, imports.%Implicit.A [template = constants.%A]
|
|
// CHECK:STDOUT: %A.call.loc4: init %empty_tuple.type = call %A.ref.loc4()
|
|
// CHECK:STDOUT: assign file.%a.var, %A.call.loc4
|
|
// CHECK:STDOUT: %NS.ref.loc5: <namespace> = name_ref NS, imports.%NS [template = imports.%NS]
|
|
// CHECK:STDOUT: %ChildNS.ref.loc5: <namespace> = name_ref ChildNS, imports.%ChildNS [template = imports.%ChildNS]
|
|
// CHECK:STDOUT: %B.ref.loc5: %B.type = name_ref B, imports.%Implicit.B [template = constants.%B]
|
|
// CHECK:STDOUT: %B.call.loc5: init %empty_tuple.type = call %B.ref.loc5()
|
|
// CHECK:STDOUT: assign file.%b.var, %B.call.loc5
|
|
// CHECK:STDOUT: %package.ref.loc7: <namespace> = name_ref package, package [template = package]
|
|
// CHECK:STDOUT: %NS.ref.loc7: <namespace> = name_ref NS, imports.%NS [template = imports.%NS]
|
|
// CHECK:STDOUT: %A.ref.loc7: %A.type = name_ref A, imports.%Implicit.A [template = constants.%A]
|
|
// CHECK:STDOUT: %A.call.loc7: init %empty_tuple.type = call %A.ref.loc7()
|
|
// CHECK:STDOUT: assign file.%package_a.var, %A.call.loc7
|
|
// CHECK:STDOUT: %package.ref.loc8: <namespace> = name_ref package, package [template = package]
|
|
// CHECK:STDOUT: %NS.ref.loc8: <namespace> = name_ref NS, imports.%NS [template = imports.%NS]
|
|
// CHECK:STDOUT: %ChildNS.ref.loc8: <namespace> = name_ref ChildNS, imports.%ChildNS [template = imports.%ChildNS]
|
|
// CHECK:STDOUT: %B.ref.loc8: %B.type = name_ref B, imports.%Implicit.B [template = constants.%B]
|
|
// CHECK:STDOUT: %B.call.loc8: init %empty_tuple.type = call %B.ref.loc8()
|
|
// CHECK:STDOUT: assign file.%package_b.var, %B.call.loc8
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|