Repository: carbon-language/carbon-lang
File: toolchain/check/keyword_modifier_set.h (C/C++)

Code before:
    Protected = 1 << 1,

    // Extern is standalone.
    Extern = 1 << 2,

    // At most one of these declaration modifiers allowed for a given
    // declaration:
    Abstract = 1 << 3,
    Base = 1 << 4,
    Default = 1 << 5,
    Export = 1 << 6,
    Extend = 1 << 7,
    Final = 1 << 8,
    Impl = 1 << 9,
    Virtual = 1 << 10,
    Returned = 1 << 11,

    // Sets of modifiers:
    Access = Private | Protected,
    Class = Abstract | Base,
    Method = Abstract | Impl | Virtual,
    ImplDecl = Extend | Final,
    Interface = Default | Final,
    Decl = Class | Method | ImplDecl | Interface | Export | Returned,
    None = 0,

    LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/Returned)
  };

  // Default construct to empty.
  explicit KeywordModifierSet() : set_(None) {}

  // Support implicit conversion so that the difference with the member enum is
  // opaque.
  // NOLINTNEXTLINE(google-explicit-constructor)
  constexpr KeywordModifierSet(RawEnumType set) : set_(set) {}

  // Adds entries to the set.
  auto Add(KeywordModifierSet set) -> void { set_ |= set.set_; }
  // Removes entries from the set.
  auto Remove(KeywordModifierSet set) -> void { set_ &= ~set.set_; }

  // Returns true if there's a non-empty set intersection.
  constexpr auto HasAnyOf(KeywordModifierSet other) const -> bool {
    return set_ & other.set_;
  }

  // Return a builder that returns the new enumeration type once a series of
  // mapping `Case`s and a final `Default` are provided. For example:
  //   ```
  //   auto e = set.ToEnum<SomeEnum>()

Review comment (suggestion):
The change from `ImplDecl` -> `Impl` here is surprising to me. `Impl` is already a part of `Method` and refers to using `impl` as a modifier keyword on virtual methods (to be replaced by `override`, see #5253 ), as opposed to `ImplDecl` which is the modifiers allowed on an `impl` declaration. It would make more sense to delete this than use `Impl` here.

Code after:
    Protected = 1 << 1,

    // Extern is standalone.
    Extern = 1 << 2,

    // Extend can be combined with Final, but no others in the group below.
    Extend = 1 << 3,

    // At most one of these declaration modifiers allowed for a given
    // declaration:
    Abstract = 1 << 4,
    Base = 1 << 5,
    Default = 1 << 6,
    Export = 1 << 7,
    Final = 1 << 8,
    Impl = 1 << 9,
    Virtual = 1 << 10,
    Returned = 1 << 11,

    // Sets of modifiers:
    Access = Private | Protected,
    Class = Abstract | Base,
    Method = Abstract | Impl | Virtual,
    ImplDecl = Extend | Final,
    Interface = Default | Final,
    Decl = Class | Method | Impl | Interface | Export | Returned,
    None = 0,

    LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/Returned)
  };

  // Default construct to empty.
  explicit KeywordModifierSet() : set_(None) {}

  // Support implicit conversion so that the difference with the member enum is
  // opaque.
  // NOLINTNEXTLINE(google-explicit-constructor)
  constexpr KeywordModifierSet(RawEnumType set) : set_(set) {}

  // Adds entries to the set.
  auto Add(KeywordModifierSet set) -> void { set_ |= set.set_; }
  // Removes entries from the set.
  auto Remove(KeywordModifierSet set) -> void { set_ &= ~set.set_; }

  // Returns true if there's a non-empty set intersection.
  constexpr auto HasAnyOf(KeywordModifierSet other) const -> bool {
    return set_ & other.set_;
  }

  // Return a builder that returns the new enumeration type once a series of
  // mapping `Case`s and a final `Default` are provided. For example: