[PATCH] D69000: [clang-tidy] new check: modernize-deprecated-iterator-base
Eugene Zelenko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 15 12:13:49 PDT 2019
Eugene.Zelenko added inline comments.
================
Comment at: clang-tools-extra/clang-tidy/modernize/DeprecatedIteratorBaseCheck.cpp:93
+ // TODO: Is there a way to get the location without lexer gymnastics?
+ auto Colon = findPreviousTokenKind(R.getBegin(), SM, LangOpts, tok::colon);
+ Token Tok = getPreviousToken(Colon, SM, LangOpts, /*SkipComments=*/true);
----------------
Please don't use auto when type is not spelled in same statement or iterator.
================
Comment at: clang-tools-extra/clang-tidy/modernize/DeprecatedIteratorBaseCheck.cpp:100
+ // ^^^^^^^^^^^^^^
+ auto Loc = (RD.bases_end() - 2)->getEndLoc();
+ R.setBegin(Lexer::getLocForEndOfToken(Loc, 0, SM, LangOpts));
----------------
Please don't use auto when type is not spelled in same statement or iterator.
================
Comment at: clang-tools-extra/clang-tidy/modernize/DeprecatedIteratorBaseCheck.cpp:115
+static SourceLocation getInsertLoc(const CXXRecordDecl &RD) {
+ const auto *TopAS = getTopAccSpecDecl(RD);
+ if (TopAS && TopAS->getAccessUnsafe() == AS_public) {
----------------
Please don't use auto when type is not spelled in same statement or iterator.
================
Comment at: clang-tools-extra/clang-tidy/modernize/DeprecatedIteratorBaseCheck.cpp:129
+static bool isOpeningRequired(const CXXRecordDecl &RD) {
+ const auto *TopAS = getTopAccSpecDecl(RD);
+ if (TopAS && TopAS->getAccessUnsafe() == AS_public) {
----------------
Please don't use auto when type is not spelled in same statement or iterator.
================
Comment at: clang-tools-extra/clang-tidy/modernize/DeprecatedIteratorBaseCheck.cpp:218
+ // Requires C++.
+ if (!getLangOpts().CPlusPlus)
+ return;
----------------
Should it check for C++17 or newer?
================
Comment at: clang-tools-extra/clang-tidy/modernize/DeprecatedIteratorBaseCheck.cpp:253
+ StringRef IndentAccSpec;
+ if (const auto *ASD = getAnyAccSpecDecl(Subj))
+ IndentAccSpec = Lexer::getIndentationForLine(ASD->getLocation(), SM);
----------------
Please don't use auto when type is not spelled in same statement or iterator.
================
Comment at: clang-tools-extra/clang-tidy/modernize/DeprecatedIteratorBaseCheck.cpp:259
+ StringRef Indent;
+ if (const auto *D = getAnyNonAccSpecDecl(Subj))
+ Indent = Lexer::getIndentationForLine(D->getLocation(), SM);
----------------
Please don't use auto when type is not spelled in same statement or iterator.
================
Comment at: clang-tools-extra/clang-tidy/modernize/DeprecatedIteratorBaseCheck.cpp:280
+ Subj, Context))) {
+ auto Range = GetRealRange(ND->getSourceRange()).getAsRange();
+ Range.setEnd(findNextTerminator(Range.getEnd(), SM, getLangOpts())
----------------
Please don't use auto when type is not spelled in same statement or iterator.
================
Comment at: clang-tools-extra/docs/ReleaseNotes.rst:133
+- New :doc:`modernize-deprecated-iterator-base
+ <clang-tidy/checks/modernize-deprecated-iterator-base>` check.
----------------
Please put in new checks list in alphabetical order.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69000/new/
https://reviews.llvm.org/D69000
More information about the cfe-commits
mailing list