Page MenuHomePhabricator

[clang-tidy] new check: modernize-deprecated-iterator-base
Needs ReviewPublic

Authored by nick on Oct 15 2019, 10:44 AM.

Details

Summary

Finds deprecated in C++17 inheritance from std::iterator and replaces it with type aliases. The check itself is not marked as C++17 because it could be applied to any project with no harm.


Because of need to catch CXXBaseSpecifier I extended clang::ast_type_traits, but locally and in a hacky way. I would be glad if someone who knows ASTMatcher internals do add a proper CXXBaseSpecifier support.

Diff Detail

Event Timeline

nick created this revision.Oct 15 2019, 10:44 AM
Eugene.Zelenko added inline comments.
clang-tools-extra/clang-tidy/modernize/DeprecatedIteratorBaseCheck.cpp
94

Please don't use auto when type is not spelled in same statement or iterator.

101

Please don't use auto when type is not spelled in same statement or iterator.

116

Please don't use auto when type is not spelled in same statement or iterator.

130

Please don't use auto when type is not spelled in same statement or iterator.

219

Should it check for C++17 or newer?

254

Please don't use auto when type is not spelled in same statement or iterator.

260

Please don't use auto when type is not spelled in same statement or iterator.

281

Please don't use auto when type is not spelled in same statement or iterator.

clang-tools-extra/docs/ReleaseNotes.rst
139

Please put in new checks list in alphabetical order.

nick updated this revision to Diff 225133.Oct 15 2019, 4:37 PM

Addressed comments.

nick marked 2 inline comments as done.Oct 15 2019, 4:44 PM
nick added inline comments.
clang-tools-extra/clang-tidy/modernize/DeprecatedIteratorBaseCheck.cpp
219

I do not think so. It is a backward compatible change. The standard never required to inherit iterators from the std::iterator, and the standard library itself had not inheriting from std::iterator iterators.

nick marked 9 inline comments as done.Oct 15 2019, 4:46 PM