devops.cpp.ast.checks.no_global_using_enum
Flag using enum declarations at namespace/global scope.
Any using enum X; (C++20) that appears directly inside a translation unit
or a named/anonymous namespace is reported as an error, since it injects every
enumerator of X into the enclosing scope. The same declaration inside a
function or class body is allowed because its effect is confined to that scope.
This is separate from noGlobalUsing so the two can be toggled independently.
To disable this check for a project set:
[cpp]
ast_check_disabled_ids = ["noGlobalUsingEnum"]
To restrict the check to (or exempt) specific enums, use the per-check table.
Names are matched exactly against the qualified enum name as written in the
source; a leading :: is ignored:
[cpp.ast_check_config.noGlobalUsingEnum]
enabled_names = ["molsys::HybridZone"]
disabled_names = ["molsys::Legacy"]
To allow specific enum names only in certain files or directories, add one or
more [[...path_exceptions]] entries:
[[cpp.ast_check_config.noGlobalUsingEnum.path_exceptions]]
names = ["molsys::LegacyZone"]
paths = ["src/legacy/"]
Classes
Flag |
- class devops.cpp.ast.checks.no_global_using_enum.NoGlobalUsingEnum[source]
Bases:
NameFilteredCheckFlag
using enum X;at global/namespace scope.The libclang Python bindings have no cursor kind for using-enum declarations: they surface as a childless, non-definition
ENUM_DECL. They are told apart from real enum declarations (and forward declarations) by their first token beingusingrather thanenum.- visit(cursor, filename)[source]
Flag the cursor if it is a global-scope
using enumdeclaration.- Parameters:
cursor (clang.Cursor) – The AST node currently being visited.
filename (str) – Path of the file being checked.
- Returns:
list[Diagnostic] – A single diagnostic if the cursor is a disallowed
using enum, otherwise an empty list.- Return type: