[PATCH] D42730: Add clang-tidy check for use of types/classes/functions from functional.h which are deprecated and removed in C++17
Alexander Kornienko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 31 03:39:07 PST 2018
alexfh added a comment.
Thank you for this new check! A few minor comments (mostly style issues).
================
Comment at: clang-tidy/modernize/AvoidFunctionalCheck.cpp:37
+void AvoidFunctionalCheck::check(const MatchFinder::MatchResult &Result) {
+ if (const auto* const un_or_binary_derived =
+ Result.Nodes.getNodeAs<clang::RecordDecl>("un_or_binary_derived")) {
----------------
Please use llvm naming conventions for locals (CamelCase).
================
Comment at: clang-tidy/modernize/AvoidFunctionalCheck.cpp:38
+ if (const auto* const un_or_binary_derived =
+ Result.Nodes.getNodeAs<clang::RecordDecl>("un_or_binary_derived")) {
+ auto* decl = clang::cast<clang::CXXRecordDecl>(un_or_binary_derived);
----------------
`clang::` is not needed here (the code is inside namespace clang).
================
Comment at: clang-tidy/modernize/AvoidFunctionalCheck.cpp:39
+ Result.Nodes.getNodeAs<clang::RecordDecl>("un_or_binary_derived")) {
+ auto* decl = clang::cast<clang::CXXRecordDecl>(un_or_binary_derived);
+ for (clang::CXXBaseSpecifier base : decl->bases()) {
----------------
`const auto *`
================
Comment at: clang-tidy/modernize/AvoidFunctionalCheck.cpp:42
+ clang::QualType base_type = base.getType();
+ auto clang_decl = base_type->getAsCXXRecordDecl();
+ if (!clang_decl) {
----------------
`const auto *`
================
Comment at: clang-tidy/modernize/AvoidFunctionalCheck.cpp:52
+ }
+ diag(base.getLocStart(), "%0 is deprecated and removed from C++17")
+ << clang_decl;
----------------
Maybe expand a bit more: "deprecated in C++11 and removed in C++17" (or "from C++17", whichever sounds better in English)?
================
Comment at: docs/ReleaseNotes.rst:63
+
+ Warns if types, classes and functions from functional.h which are deprecated
+ and removed in C++17 are used.
----------------
".h" is an anachronism, I'd write "from the `<functional>` header" or something like that. Same in other places.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D42730
More information about the cfe-commits
mailing list