devops.cpp.ast.checks.prefer_mstd_copy_move_macros
Flag hand-written deleted copy/move members that a macro should replace.
Code bases using mstd delete copy and move operations with
MSTD_NO_COPY(X) and MSTD_NO_MOVE(X) instead of spelling out:
X(const X &) = delete;
X &operator=(const X &) = delete;
X(X &&) = delete;
X &operator=(X &&) = delete;
Members produced by a macro expansion (MSTD_NO_COPY, MSTD_NO_MOVE,
MSTD_RAII_NO_MOVE, …) are not flagged: only a = delete written in
the checked file’s own tokens is.
The suggested macro names are configurable:
[cpp.ast_check_config.preferMstdCopyMoveMacros] copy_macro = “MSTD_NO_COPY” move_macro = “MSTD_NO_MOVE”
To disable this check for a project set:
[cpp]
ast_check_disabled_ids = ["preferMstdCopyMoveMacros"]
Classes
Flag hand-written |
- class devops.cpp.ast.checks.prefer_mstd_copy_move_macros.PreferMstdCopyMoveMacros[source]
Bases:
CheckFlag hand-written
= deletecopy/move constructors and assignments.- configure(config)[source]
Load the suggested macro names from the check’s TOML config block.
- Parameters:
config (dict) – Optional keys
copy_macroandmove_macro, each a macro name (C identifier).- Raises:
ConfigError – If a configured macro name is not a valid identifier string.
- Return type:
None
- visit(cursor, filename)[source]
Flag a hand-written deleted copy/move constructor or assignment.
- 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 cursor is a hand-written deleted copy/move member, otherwise an empty list.
- Return type: