Clazy emits wrong detach warnings for known-to-be local containers: Model::reset() { beginResetModel(); constexpr int preallocSize = 160; QVarLengthArray<RawDataEntry, preallocSize> initialEntries = { ... }; m_data.clear(); for (const auto &entry: initialEntries) // -Wclazy-range-loop] m_data.insert(entry.id, entry); endResetModel(); }
"Known to be local containers" - they don't leave scope and are not passed to any external function.
Git commit 642c2d801b288e0def3517870a57639afe1a5c74 by Sergio Martins. Committed on 20/08/2016 at 21:07. Pushed by smartins into branch 'master'. range-loop: Reduce false positives If the container is local and is not passed to any function, lets not warn. Not closing bug yet, still can be improved. M +8 -3 checks/level1/range-loop.cpp M +15 -3 tests/range-loop/main.cpp M +6 -5 tests/range-loop/main.cpp.expected http://commits.kde.org/clazy/642c2d801b288e0def3517870a57639afe1a5c74
Git commit a2cc115a8e5955947e13564fe2ebd6d15667ac1e by Sergio Martins. Committed on 21/08/2016 at 15:57. Pushed by smartins into branch 'master'. range-loop: Don't warn if the container doesn't detach M +4 -4 QtUtils.cpp M +4 -1 QtUtils.h M +3 -3 StmtBodyRange.h M +2 -0 Utils.cpp M +3 -1 checks/level1/range-loop.cpp M +8 -0 tests/range-loop/main.cpp http://commits.kde.org/clazy/a2cc115a8e5955947e13564fe2ebd6d15667ac1e