Refactor KeywordModifierSet to provide a class API (#4003)

This is primarily to avoid the use of `!!` in code, trying not to create
too much code as a result (obviously still a net increase). Also
refactoring to its own file to make the enum easier to find.

Note, NodeCategory does similar, I might propose similar there if
everyone's good with the API. However, that's just two, so creating
something like enum_base felt like too much.
This commit is contained in:
Jon Ross-Perkins
2024-05-29 20:52:31 +00:00
committed by GitHub
parent 28170c7867
commit 512583d744
12 changed files with 134 additions and 84 deletions
+4 -4
View File
@@ -229,18 +229,18 @@ static auto BuildFunctionDecl(Context& context,
// Process modifiers.
auto modifiers = DiagnoseModifiers(context, is_definition,
name_context.enclosing_scope_id);
if (!!(modifiers & KeywordModifierSet::Access)) {
if (modifiers.HasAnyOf(KeywordModifierSet::Access)) {
context.TODO(context.decl_state_stack().innermost().modifier_node_id(
ModifierOrder::Access),
"access modifier");
}
bool is_extern = !!(modifiers & KeywordModifierSet::Extern);
if (!!(modifiers & KeywordModifierSet::Method)) {
bool is_extern = modifiers.HasAnyOf(KeywordModifierSet::Extern);
if (modifiers.HasAnyOf(KeywordModifierSet::Method)) {
context.TODO(context.decl_state_stack().innermost().modifier_node_id(
ModifierOrder::Decl),
"method modifier");
}
if (!!(modifiers & KeywordModifierSet::Interface)) {
if (modifiers.HasAnyOf(KeywordModifierSet::Interface)) {
// TODO: Once we are saving the modifiers for a function, add check that
// the function may only be defined if it is marked `default` or `final`.
context.TODO(context.decl_state_stack().innermost().modifier_node_id(