devops.cpp.ast.checks.no_in_class_member_definition
Flag member functions whose body is written inside the class definition.
Member functions are declared in the class and defined outside of it
(void Foo::bar() { ... }), also for classes that live only in a .cpp
file. This keeps class definitions short and readable as an interface.
Flagged are in-class bodies of ordinary, static, operator and conversion
member functions, constructors, destructors and member function templates,
in classes, structs and unions, nested classes and class templates.
Templates are flagged too: their members can still be defined after the
class in the same header (or an included .tpp file).
Never flagged:
declarations without a body, pure virtual (
= 0),= defaultand= deletemembers;member functions synthesized by a macro (e.g.
MSTD_ENUMor GTest’sTEST/TEST_F), detected via the macro instantiation that covers the member’s location;members of local classes (declared inside a function body) and of unnamed classes, since C++ offers no way to define those outside the class;
in-class
friendfunction definitions (hidden friends), which are not member functions;lambdas, which are expressions rather than member functions.
To disable this check for a project set:
[cpp]
ast_check_disabled_ids = ["noInClassMemberDefinition"]
Classes
Flag member functions defined inside their class body. |
- class devops.cpp.ast.checks.no_in_class_member_definition.NoInClassMemberDefinition[source]
Bases:
CheckFlag member functions defined inside their class body.
Reporting is deferred to finalize(): whether a member was synthesized by a macro is only known once every
MACRO_INSTANTIATIONcursor in the file has been seen.- visit(cursor, filename)[source]
Record macro instantiations and in-class member definitions.
- Parameters:
cursor (clang.Cursor) – The AST node currently being visited.
filename (str) – Path of the file being checked.
- Returns:
list[Diagnostic] – Always empty; diagnostics are emitted from finalize().
- Return type: