@@ -835,7 +835,7 @@ struct ImportIRInstId : public IdBase<ImportIRInstId> {
835835 using ValueType = ImportIRInst;
836836
837837 // ImportIRInstId is restricted so that it can fit into LocId.
838- static constexpr int32_t BitsWithNodeId = 29 ;
838+ static constexpr int BitsWithNodeId = 30 ;
839839
840840 // The maximum ID, non-inclusive.
841841 static constexpr int Max = (1 << BitsWithNodeId) - Parse::NodeId::Max - 2 ;
@@ -857,17 +857,17 @@ struct ImportIRInstId : public IdBase<ImportIRInstId> {
857857// - NodeId: negative values starting after None; the 24 bit NodeId range.
858858// - [-2, -2 - (1 << 24))
859859// - ImportIRInstId: remaining negative values; after NodeId, fills out negative
860- // values to 29 bits.
861- // - [-2 - (1 << 24), -(1 << 29 ))
860+ // values to 30 bits.
861+ // - [-2 - (1 << 24), -(1 << 30 ))
862862//
863- // In addition, two bits are used for flags: `ImplicitBit` and `TokenOnlyBit `.
864- // Note that these can only be used with negative, non-`InstId` values.
863+ // In addition, one bit is used for flags: `ImplicitBit`.
864+ // Note that this can only be used with negative, non-`InstId` values.
865865//
866866// Use `InstStore::GetCanonicalLocId()` to get a canonical `LocId` which will
867867// not be backed by an `InstId`. Note that the canonical `LocId` may be `None`
868868// even when the original `LocId` was not, so this operation needs to be done
869869// before checking `has_value()`. Only canonical locations can be converted with
870- // `ToImplicit()` or `ToTokenOnly()` .
870+ // `ToImplicit()`.
871871struct LocId : public IdBase <LocId> {
872872 // The contained index kind.
873873 enum class Kind {
@@ -910,20 +910,6 @@ struct LocId : public IdBase<LocId> {
910910 return *this ;
911911 }
912912
913- // Forms an equivalent `LocId` for a token-only diagnostic location. Requires
914- // a canonical location. See `InstStore::GetCanonicalLocId()`.
915- //
916- // TODO: Consider making this a part of check/ diagnostics instead, as a free
917- // function operation on `LocIdForDiagnostics`?
918- // https://github.com/carbon-language/carbon-lang/pull/5355#discussion_r2064113186
919- auto ToTokenOnly () const -> LocId {
920- CARBON_CHECK (kind () != Kind::InstId);
921- if (has_value ()) {
922- return LocId (index & ~TokenOnlyBit);
923- }
924- return *this ;
925- }
926-
927913 // Returns the kind of the `LocId`.
928914 auto kind () const -> Kind {
929915 if (!has_value ()) {
@@ -944,15 +930,6 @@ struct LocId : public IdBase<LocId> {
944930 return (kind () == Kind::NodeId) && (index & ImplicitBit) == 0 ;
945931 }
946932
947- // Returns true if the location is token-only for diagnostics.
948- //
949- // This means the displayed location will include only the location's specific
950- // parse node, instead of also including its descendants. As such, this can
951- // only be true for locations backed by a `NodeId`.
952- auto is_token_only () const -> bool {
953- return kind () != Kind::InstId && (index & TokenOnlyBit) == 0 ;
954- }
955-
956933 // Returns the equivalent `ImportIRInstId` when `kind()` matches or is `None`.
957934 // Note that the returned `ImportIRInstId` only identifies a location; it is
958935 // not correct to interpret it as the instruction from which another
@@ -987,18 +964,14 @@ struct LocId : public IdBase<LocId> {
987964 // for `NodeId`.
988965 static constexpr int32_t ImplicitBit = 1 << 30 ;
989966
990- // See `is_token_only` for the use. This only applies for canonical locations
991- // (i.e. those containing `NodeId` or `ImportIRInstId`).
992- static constexpr int32_t TokenOnlyBit = 1 << 29 ;
993-
994967 // The value of the 0 index for each of `NodeId` and `ImportIRInstId`.
995968 static constexpr int32_t FirstNodeId = NoneIndex - 1 ;
996969 static constexpr int32_t FirstImportIRInstId =
997970 FirstNodeId - Parse::NodeId::Max;
998971
999972 auto index_without_flags () const -> int32_t {
1000973 CARBON_DCHECK (index < NoneIndex, " Only for NodeId and ImportIRInstId" );
1001- return index | ImplicitBit | TokenOnlyBit ;
974+ return index | ImplicitBit;
1002975 }
1003976};
1004977
0 commit comments