From 7e06b703bf41e9e7b81a3fd504ebe9b6c287157b Mon Sep 17 00:00:00 2001 From: Jon Ross-Perkins Date: Thu, 1 Feb 2024 20:25:50 -0800 Subject: [PATCH] Clean up some redundant name qualifiers. (#3681) --- toolchain/parse/handle_impl.cpp | 8 +++---- toolchain/sem_ir/ids.h | 38 +++++++++++++++------------------ 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/toolchain/parse/handle_impl.cpp b/toolchain/parse/handle_impl.cpp index e1c3da171e3a..e348111d8de6 100644 --- a/toolchain/parse/handle_impl.cpp +++ b/toolchain/parse/handle_impl.cpp @@ -6,7 +6,7 @@ namespace Carbon::Parse { -static auto ExpectAsOrTypeExpression(Carbon::Parse::Context& context) -> void { +static auto ExpectAsOrTypeExpression(Context& context) -> void { if (context.PositionIs(Lex::TokenKind::As)) { // as ... context.AddLeafNode(NodeKind::DefaultSelfImplAs, context.Consume()); @@ -18,7 +18,7 @@ static auto ExpectAsOrTypeExpression(Carbon::Parse::Context& context) -> void { } } -auto HandleImplAfterIntroducer(Carbon::Parse::Context& context) -> void { +auto HandleImplAfterIntroducer(Context& context) -> void { auto state = context.PopState(); state.state = State::DeclOrDefinitionAsImpl; context.PushState(state); @@ -48,7 +48,7 @@ auto HandleImplAfterIntroducer(Carbon::Parse::Context& context) -> void { } } -auto HandleImplAfterForall(Carbon::Parse::Context& context) -> void { +auto HandleImplAfterForall(Context& context) -> void { auto state = context.PopState(); if (state.has_error) { context.ReturnErrorOnState(); @@ -61,7 +61,7 @@ auto HandleImplAfterForall(Carbon::Parse::Context& context) -> void { ExpectAsOrTypeExpression(context); } -auto HandleImplBeforeAs(Carbon::Parse::Context& context) -> void { +auto HandleImplBeforeAs(Context& context) -> void { auto state = context.PopState(); if (auto as = context.ConsumeIf(Lex::TokenKind::As)) { context.AddNode(NodeKind::TypeImplAs, *as, state.subtree_start, diff --git a/toolchain/sem_ir/ids.h b/toolchain/sem_ir/ids.h index 3f8ea4647f57..971cc3d8a7cc 100644 --- a/toolchain/sem_ir/ids.h +++ b/toolchain/sem_ir/ids.h @@ -71,7 +71,7 @@ struct InstId : public IdBase, public Printable { } }; -constexpr InstId InstId::Invalid = InstId(InstId::InvalidIndex); +constexpr InstId InstId::Invalid = InstId(InvalidIndex); #define CARBON_SEM_IR_BUILTIN_KIND_NAME(Name) \ constexpr InstId InstId::Builtin##Name = \ @@ -178,7 +178,7 @@ struct BindNameId : public IdBase, public Printable { } }; -constexpr BindNameId BindNameId::Invalid = BindNameId(BindNameId::InvalidIndex); +constexpr BindNameId BindNameId::Invalid = BindNameId(InvalidIndex); // The ID of a function. struct FunctionId : public IdBase, public Printable { @@ -194,7 +194,7 @@ struct FunctionId : public IdBase, public Printable { } }; -constexpr FunctionId FunctionId::Invalid = FunctionId(FunctionId::InvalidIndex); +constexpr FunctionId FunctionId::Invalid = FunctionId(InvalidIndex); // The ID of a class. struct ClassId : public IdBase, public Printable { @@ -210,7 +210,7 @@ struct ClassId : public IdBase, public Printable { } }; -constexpr ClassId ClassId::Invalid = ClassId(ClassId::InvalidIndex); +constexpr ClassId ClassId::Invalid = ClassId(InvalidIndex); // The ID of an interface. struct InterfaceId : public IdBase, public Printable { @@ -226,8 +226,7 @@ struct InterfaceId : public IdBase, public Printable { } }; -constexpr InterfaceId InterfaceId::Invalid = - InterfaceId(InterfaceId::InvalidIndex); +constexpr InterfaceId InterfaceId::Invalid = InterfaceId(InvalidIndex); // The ID of an imported IR. struct ImportIRId : public IdBase, public Printable { @@ -321,12 +320,12 @@ struct NameId : public IdBase, public Printable { } }; -constexpr NameId NameId::Invalid = NameId(NameId::InvalidIndex); -constexpr NameId NameId::SelfValue = NameId(NameId::InvalidIndex - 1); -constexpr NameId NameId::SelfType = NameId(NameId::InvalidIndex - 2); -constexpr NameId NameId::ReturnSlot = NameId(NameId::InvalidIndex - 3); -constexpr NameId NameId::PackageNamespace = NameId(NameId::InvalidIndex - 4); -constexpr NameId NameId::Base = NameId(NameId::InvalidIndex - 5); +constexpr NameId NameId::Invalid = NameId(InvalidIndex); +constexpr NameId NameId::SelfValue = NameId(InvalidIndex - 1); +constexpr NameId NameId::SelfType = NameId(InvalidIndex - 2); +constexpr NameId NameId::ReturnSlot = NameId(InvalidIndex - 3); +constexpr NameId NameId::PackageNamespace = NameId(InvalidIndex - 4); +constexpr NameId NameId::Base = NameId(InvalidIndex - 5); constexpr int NameId::NonIndexValueCount = 6; // Enforce the link between SpecialValueCount and the last special value. static_assert(NameId::NonIndexValueCount == -NameId::Base.index); @@ -347,8 +346,7 @@ struct NameScopeId : public IdBase, public Printable { } }; -constexpr NameScopeId NameScopeId::Invalid = - NameScopeId(NameScopeId::InvalidIndex); +constexpr NameScopeId NameScopeId::Invalid = NameScopeId(InvalidIndex); constexpr NameScopeId NameScopeId::Package = NameScopeId(0); // The ID of an instruction block. @@ -387,10 +385,8 @@ struct InstBlockId : public IdBase, public Printable { constexpr InstBlockId InstBlockId::Empty = InstBlockId(0); constexpr InstBlockId InstBlockId::Exports = InstBlockId(1); -constexpr InstBlockId InstBlockId::Invalid = - InstBlockId(InstBlockId::InvalidIndex); -constexpr InstBlockId InstBlockId::Unreachable = - InstBlockId(InstBlockId::InvalidIndex - 1); +constexpr InstBlockId InstBlockId::Invalid = InstBlockId(InvalidIndex); +constexpr InstBlockId InstBlockId::Unreachable = InstBlockId(InvalidIndex - 1); // The ID of a type. struct TypeId : public IdBase, public Printable { @@ -418,9 +414,9 @@ struct TypeId : public IdBase, public Printable { } }; -constexpr TypeId TypeId::TypeType = TypeId(TypeId::InvalidIndex - 2); -constexpr TypeId TypeId::Error = TypeId(TypeId::InvalidIndex - 1); -constexpr TypeId TypeId::Invalid = TypeId(TypeId::InvalidIndex); +constexpr TypeId TypeId::TypeType = TypeId(InvalidIndex - 2); +constexpr TypeId TypeId::Error = TypeId(InvalidIndex - 1); +constexpr TypeId TypeId::Invalid = TypeId(InvalidIndex); // The ID of a type block. struct TypeBlockId : public IdBase, public Printable {