This is an archive of the discontinued LLVM Phabricator instance.

[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.

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
136

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

First of all I'd definitely wait until a patch to include ASTMatcher support for CXXBaseSpecifier lands before progressing with this.
Secondly this issue should be warned on by clang when compiling with c++17 with some stdlib support, libc++ should mark iterator as deprecated when compiling with c++17.
Having said that this still has value as the fix its are helpful.

nick updated this revision to Diff 336533.Apr 9 2021, 11:46 AM
nick edited the summary of this revision. (Show Details)
nick added reviewers: njames93, steveire.

Rebased. Now using native cxxBaseSpecifier and hasDirectBase.