GeneralPurpose-UseOfDeprecatedLanguageFeatures¶
Deprecated features should not be used
Required inputs: IR
Bad code (deprecated auto_ptr):
std::auto_ptr<int> ptr(new int(42)); // ERROR: auto_ptr is deprecated std::auto_ptr<int> copy = ptr; // ERROR: transfer of ownership is confusing
Good code (using unique_ptr):
std::unique_ptr<int> ptr(new int(42)); // OK: clear ownership semantics auto copy = std::move(ptr); // OK: explicit ownership transfer
Bad code (dynamic_exception_specifications):
void function() throw(std::runtime_error) { // ERROR: deprecated specification
// ...
}
Good code (using noexcept):
void function() noexcept { // OK: modern exception specification
// ...
}
Bad code (register keyword):
register int counter = 0; // ERROR: register keyword is deprecated
for (int i = 0; i < 10; ++i) {
counter += i;
}
Good code (compiler optimization):
int counter = 0; // OK: let compiler optimize
for (int i = 0; i < 10; ++i) {
counter += i;
}
Deprecated features include:
std::auto_ptr(usestd::unique_ptrorstd::shared_ptr)- Dynamic exception specifications
throw(...)(use noexcept) registerkeyword (compiler does optimization)std::codecvtfunctions (usestd::locale)volatilefor synchronization (usestd::atomic)- Implicit copy operations (use explicit
=defaultor=delete)
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
cafe_message |
{} |
None |
False |
deprecated_implicit_copy |
Class with deprecated implicit {}. |
None |
False |
lib_header_entity_use |
Usage of forbidden entity from <{}>. |
None |
False |
lib_header_include |
Unit includes <{}>. |
None |
False |
throw_in_decl |
Do not specify any exceptions in signatures. |
None |
False |
type_used |
The std::auto_ptr shall not be used. |
None |
False |
Options¶
This rule shares the following common options: exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
allowed_symbols¶
allowed_symbols : set[str] = {'NULL', 'size_t'}
NULL and size_t which are defined
in multiple headers).
header¶
header : set[str] = set()
message_predicate¶
message_predicate : typing.Callable[[Cafe_Message], bool] | None = None
True for messages to
report.
report_class_if_deprecated_smf_unused¶
report_class_if_deprecated_smf_unused : bool = False
reported_severities¶
reported_severities : set[str] = {'error', 'remark', 'warning'}
use_error_number¶
use_error_number : bool = False
use_rule_severity¶
use_rule_severity : bool = False
user_header¶
user_header : set[str] = set()