Qt-StrictIterators¶
Warns when iterator objects are implicitly cast to const_iterator
Required inputs: IR
iterator objects are implicitly cast to const_iterator.
This is mostly equivalent to passing -DQT_STRICT_ITERATORS to the compiler.
This prevents detachments but also caches subtle bugs such as:
QHash wrong;
if (wrong.find(1) == wrong.cend()) {
qDebug() << "Not found";
} else {
qDebug() << "Found"; // find() detached the container before cend() was called, so it prints "Found"
}
QHash right;
if (right.constFind(1) == right.cend()) {
qDebug() << "Not found"; // This is correct now !
} else {
qDebug() << "Found";
} This rule is based on clazy rule strict-iterators
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
bad_mix |
Mixing iterators with const_iterators. |
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
level¶
level : int = 0