From eb9d944419a6048fdbd20b4d7766552df92b7f2a Mon Sep 17 00:00:00 2001 From: Alexander Kornienko Date: Wed, 28 Feb 2018 23:47:15 +0000 Subject: [PATCH] [clang-tidy] Another batch of checks to rename from misc- to bugprone-. Summary: clang-tidy/rename_check.py {misc,bugprone}-suspicious-semicolon clang-tidy/rename_check.py {misc,bugprone}-suspicious-string-compare clang-tidy/rename_check.py {misc,bugprone}-swapped-arguments clang-tidy/rename_check.py {misc,bugprone}-undelegated-constructor --check_class_name UndelegatedConstructor Reviewers: hokein, sammccall, aaron.ballman Subscribers: klimek, mgorny, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D43870 llvm-svn: 326386 --- .../clang-tidy/bugprone/BugproneTidyModule.cpp | 12 ++++++++++++ clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt | 4 ++++ .../{misc => bugprone}/SuspiciousSemicolonCheck.cpp | 4 ++-- .../{misc => bugprone}/SuspiciousSemicolonCheck.h | 12 ++++++------ .../SuspiciousStringCompareCheck.cpp | 4 ++-- .../SuspiciousStringCompareCheck.h | 12 ++++++------ .../{misc => bugprone}/SwappedArgumentsCheck.cpp | 4 ++-- .../{misc => bugprone}/SwappedArgumentsCheck.h | 10 +++++----- .../UndelegatedConstructorCheck.cpp} | 8 ++++---- .../UndelegatedConstructorCheck.h} | 6 +++--- .../clang-tidy/hicpp/HICPPTidyModule.cpp | 4 ++-- clang-tools-extra/clang-tidy/misc/CMakeLists.txt | 4 ---- clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp | 12 ------------ clang-tools-extra/docs/ReleaseNotes.rst | 12 ++++++++++++ ...micolon.rst => bugprone-suspicious-semicolon.rst} | 6 +++--- ...re.rst => bugprone-suspicious-string-compare.rst} | 6 +++--- .../clang-tidy/checks/bugprone-swapped-arguments.rst | 6 ++++++ ...ctor.rst => bugprone-undelegated-constructor.rst} | 7 +++---- .../checks/hicpp-undelegated-constructor.rst | 4 ++-- clang-tools-extra/docs/clang-tidy/checks/list.rst | 10 +++++----- .../clang-tidy/checks/misc-swapped-arguments.rst | 7 ------- ...il.cpp => bugprone-suspicious-semicolon-fail.cpp} | 6 +++--- ...micolon.cpp => bugprone-suspicious-semicolon.cpp} | 6 +++--- ...ompare.c => bugprone-suspicious-string-compare.c} | 8 ++++---- ...re.cpp => bugprone-suspicious-string-compare.cpp} | 8 ++++---- ...-arguments.cpp => bugprone-swapped-arguments.cpp} | 2 +- ...pp => bugprone-undelegated-constructor-cxx98.cpp} | 2 +- ...ctor.cpp => bugprone-undelegated-constructor.cpp} | 4 ++-- .../test/clang-tidy/objc-arc-and-properties.m | 4 ++-- .../test/clang-tidy/objc-no-arc-or-properties.m | 4 ++-- 30 files changed, 104 insertions(+), 94 deletions(-) rename clang-tools-extra/clang-tidy/{misc => bugprone}/SuspiciousSemicolonCheck.cpp (98%) rename clang-tools-extra/clang-tidy/{misc => bugprone}/SuspiciousSemicolonCheck.h (71%) rename clang-tools-extra/clang-tidy/{misc => bugprone}/SuspiciousStringCompareCheck.cpp (99%) rename clang-tools-extra/clang-tidy/{misc => bugprone}/SuspiciousStringCompareCheck.h (73%) rename clang-tools-extra/clang-tidy/{misc => bugprone}/SwappedArgumentsCheck.cpp (98%) rename clang-tools-extra/clang-tidy/{misc => bugprone}/SwappedArgumentsCheck.h (75%) rename clang-tools-extra/clang-tidy/{misc/UndelegatedConstructor.cpp => bugprone/UndelegatedConstructorCheck.cpp} (94%) rename clang-tools-extra/clang-tidy/{misc/UndelegatedConstructor.h => bugprone/UndelegatedConstructorCheck.h} (91%) rename clang-tools-extra/docs/clang-tidy/checks/{misc-suspicious-semicolon.rst => bugprone-suspicious-semicolon.rst} (94%) rename clang-tools-extra/docs/clang-tidy/checks/{misc-suspicious-string-compare.rst => bugprone-suspicious-string-compare.rst} (94%) create mode 100644 clang-tools-extra/docs/clang-tidy/checks/bugprone-swapped-arguments.rst rename clang-tools-extra/docs/clang-tidy/checks/{misc-undelegated-constructor.rst => bugprone-undelegated-constructor.rst} (63%) delete mode 100644 clang-tools-extra/docs/clang-tidy/checks/misc-swapped-arguments.rst rename clang-tools-extra/test/clang-tidy/{misc-suspicious-semicolon-fail.cpp => bugprone-suspicious-semicolon-fail.cpp} (78%) rename clang-tools-extra/test/clang-tidy/{misc-suspicious-semicolon.cpp => bugprone-suspicious-semicolon.cpp} (91%) rename clang-tools-extra/test/clang-tidy/{misc-suspicious-string-compare.c => bugprone-suspicious-string-compare.c} (87%) rename clang-tools-extra/test/clang-tidy/{misc-suspicious-string-compare.cpp => bugprone-suspicious-string-compare.cpp} (97%) rename clang-tools-extra/test/clang-tidy/{misc-swapped-arguments.cpp => bugprone-swapped-arguments.cpp} (97%) rename clang-tools-extra/test/clang-tidy/{misc-undelegated-constructor-cxx98.cpp => bugprone-undelegated-constructor-cxx98.cpp} (76%) rename clang-tools-extra/test/clang-tidy/{misc-undelegated-constructor.cpp => bugprone-undelegated-constructor.cpp} (92%) diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp index 8ce227217405..ff35641318ee 100644 --- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp @@ -33,8 +33,12 @@ #include "SuspiciousEnumUsageCheck.h" #include "SuspiciousMemsetUsageCheck.h" #include "SuspiciousMissingCommaCheck.h" +#include "SuspiciousSemicolonCheck.h" +#include "SuspiciousStringCompareCheck.h" +#include "SwappedArgumentsCheck.h" #include "ThrowKeywordMissingCheck.h" #include "UndefinedMemoryManipulationCheck.h" +#include "UndelegatedConstructorCheck.h" #include "UseAfterMoveCheck.h" #include "VirtualNearMissCheck.h" @@ -91,10 +95,18 @@ public: "bugprone-suspicious-memset-usage"); CheckFactories.registerCheck( "bugprone-suspicious-missing-comma"); + CheckFactories.registerCheck( + "bugprone-suspicious-semicolon"); + CheckFactories.registerCheck( + "bugprone-suspicious-string-compare"); + CheckFactories.registerCheck( + "bugprone-swapped-arguments"); CheckFactories.registerCheck( "bugprone-throw-keyword-missing"); CheckFactories.registerCheck( "bugprone-undefined-memory-manipulation"); + CheckFactories.registerCheck( + "bugprone-undelegated-constructor"); CheckFactories.registerCheck( "bugprone-use-after-move"); CheckFactories.registerCheck( diff --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt index 42e7b4fdf7b6..a34d3fd9abdb 100644 --- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt @@ -25,8 +25,12 @@ add_clang_library(clangTidyBugproneModule SuspiciousEnumUsageCheck.cpp SuspiciousMemsetUsageCheck.cpp SuspiciousMissingCommaCheck.cpp + SuspiciousSemicolonCheck.cpp + SuspiciousStringCompareCheck.cpp + SwappedArgumentsCheck.cpp ThrowKeywordMissingCheck.cpp UndefinedMemoryManipulationCheck.cpp + UndelegatedConstructorCheck.cpp UseAfterMoveCheck.cpp VirtualNearMissCheck.cpp diff --git a/clang-tools-extra/clang-tidy/misc/SuspiciousSemicolonCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp similarity index 98% rename from clang-tools-extra/clang-tidy/misc/SuspiciousSemicolonCheck.cpp rename to clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp index e39a459978d1..d7f51d0d8bc2 100644 --- a/clang-tools-extra/clang-tidy/misc/SuspiciousSemicolonCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp @@ -16,7 +16,7 @@ using namespace clang::ast_matchers; namespace clang { namespace tidy { -namespace misc { +namespace bugprone { void SuspiciousSemicolonCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher( @@ -72,6 +72,6 @@ void SuspiciousSemicolonCheck::check(const MatchFinder::MatchResult &Result) { << FixItHint::CreateRemoval(SourceRange(LocStart, LocEnd)); } -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang diff --git a/clang-tools-extra/clang-tidy/misc/SuspiciousSemicolonCheck.h b/clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.h similarity index 71% rename from clang-tools-extra/clang-tidy/misc/SuspiciousSemicolonCheck.h rename to clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.h index 6791ba6c7baa..adfced1a1e9a 100644 --- a/clang-tools-extra/clang-tidy/misc/SuspiciousSemicolonCheck.h +++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.h @@ -7,20 +7,20 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SUSPICIOUS_SEMICOLON_H -#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SUSPICIOUS_SEMICOLON_H +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SUSPICIOUSSEMICOLONCHECK_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SUSPICIOUSSEMICOLONCHECK_H #include "../ClangTidy.h" namespace clang { namespace tidy { -namespace misc { +namespace bugprone { /// This check finds semicolon that modifies the meaning of the program /// unintendedly. /// /// For the user-facing documentation see: -/// http://clang.llvm.org/extra/clang-tidy/checks/misc-suspicious-semicolon.html +/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-suspicious-semicolon.html class SuspiciousSemicolonCheck : public ClangTidyCheck { public: SuspiciousSemicolonCheck(StringRef Name, ClangTidyContext *Context) @@ -29,8 +29,8 @@ public: void check(const ast_matchers::MatchFinder::MatchResult &Result) override; }; -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang -#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SUSPICIOUS_SEMICOLON_H +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SUSPICIOUSSEMICOLONCHECK_H diff --git a/clang-tools-extra/clang-tidy/misc/SuspiciousStringCompareCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp similarity index 99% rename from clang-tools-extra/clang-tidy/misc/SuspiciousStringCompareCheck.cpp rename to clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp index 641200cbb05b..0cc62157b232 100644 --- a/clang-tools-extra/clang-tidy/misc/SuspiciousStringCompareCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp @@ -18,7 +18,7 @@ using namespace clang::ast_matchers; namespace clang { namespace tidy { -namespace misc { +namespace bugprone { // Semicolon separated list of known string compare-like functions. The list // must ends with a semicolon. @@ -213,6 +213,6 @@ void SuspiciousStringCompareCheck::check( } } -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang diff --git a/clang-tools-extra/clang-tidy/misc/SuspiciousStringCompareCheck.h b/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.h similarity index 73% rename from clang-tools-extra/clang-tidy/misc/SuspiciousStringCompareCheck.h rename to clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.h index 0e9bd45c52bf..38a9d9cdd6b1 100644 --- a/clang-tools-extra/clang-tidy/misc/SuspiciousStringCompareCheck.h +++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.h @@ -7,19 +7,19 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SUSPICIOUS_STRING_COMPARE_H -#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SUSPICIOUS_STRING_COMPARE_H +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SUSPICIOUSSTRINGCOMPARECHECK_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SUSPICIOUSSTRINGCOMPARECHECK_H #include "../ClangTidy.h" namespace clang { namespace tidy { -namespace misc { +namespace bugprone { /// Find suspicious calls to string compare functions. /// /// For the user-facing documentation see: -/// http://clang.llvm.org/extra/clang-tidy/checks/misc-suspicious-string-compare.html +/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-suspicious-string-compare.html class SuspiciousStringCompareCheck : public ClangTidyCheck { public: SuspiciousStringCompareCheck(StringRef Name, ClangTidyContext *Context); @@ -33,8 +33,8 @@ private: const std::string StringCompareLikeFunctions; }; -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang -#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SUSPICIOUS_STRING_COMPARE_H +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SUSPICIOUSSTRINGCOMPARECHECK_H diff --git a/clang-tools-extra/clang-tidy/misc/SwappedArgumentsCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SwappedArgumentsCheck.cpp similarity index 98% rename from clang-tools-extra/clang-tidy/misc/SwappedArgumentsCheck.cpp rename to clang-tools-extra/clang-tidy/bugprone/SwappedArgumentsCheck.cpp index e4dc5ca056a4..64d3eaf50468 100644 --- a/clang-tools-extra/clang-tidy/misc/SwappedArgumentsCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SwappedArgumentsCheck.cpp @@ -17,7 +17,7 @@ using namespace clang::ast_matchers; namespace clang { namespace tidy { -namespace misc { +namespace bugprone { void SwappedArgumentsCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher(callExpr().bind("call"), this); @@ -97,6 +97,6 @@ void SwappedArgumentsCheck::check(const MatchFinder::MatchResult &Result) { } } -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang diff --git a/clang-tools-extra/clang-tidy/misc/SwappedArgumentsCheck.h b/clang-tools-extra/clang-tidy/bugprone/SwappedArgumentsCheck.h similarity index 75% rename from clang-tools-extra/clang-tidy/misc/SwappedArgumentsCheck.h rename to clang-tools-extra/clang-tidy/bugprone/SwappedArgumentsCheck.h index ed3266195cf2..59ec3add3b04 100644 --- a/clang-tools-extra/clang-tidy/misc/SwappedArgumentsCheck.h +++ b/clang-tools-extra/clang-tidy/bugprone/SwappedArgumentsCheck.h @@ -7,14 +7,14 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SWAPPEDARGUMENTSCHECK_H -#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SWAPPEDARGUMENTSCHECK_H +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SWAPPEDARGUMENTSCHECK_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SWAPPEDARGUMENTSCHECK_H #include "../ClangTidy.h" namespace clang { namespace tidy { -namespace misc { +namespace bugprone { /// Finds potentially swapped arguments by looking at implicit conversions. class SwappedArgumentsCheck : public ClangTidyCheck { @@ -25,8 +25,8 @@ public: void check(const ast_matchers::MatchFinder::MatchResult &Result) override; }; -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang -#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SWAPPEDARGUMENTSCHECK_H +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SWAPPEDARGUMENTSCHECK_H diff --git a/clang-tools-extra/clang-tidy/misc/UndelegatedConstructor.cpp b/clang-tools-extra/clang-tidy/bugprone/UndelegatedConstructorCheck.cpp similarity index 94% rename from clang-tools-extra/clang-tidy/misc/UndelegatedConstructor.cpp rename to clang-tools-extra/clang-tidy/bugprone/UndelegatedConstructorCheck.cpp index f42f1c5af9e3..f47ad7e7c479 100644 --- a/clang-tools-extra/clang-tidy/misc/UndelegatedConstructor.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/UndelegatedConstructorCheck.cpp @@ -1,4 +1,4 @@ -//===--- UndelegatedConstructor.cpp - clang-tidy --------------------------===// +//===--- UndelegatedConstructorCheck.cpp - clang-tidy --------------------------===// // // The LLVM Compiler Infrastructure // @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "UndelegatedConstructor.h" +#include "UndelegatedConstructorCheck.h" #include "clang/AST/ASTContext.h" #include "clang/Lex/Lexer.h" @@ -15,7 +15,7 @@ using namespace clang::ast_matchers; namespace clang { namespace tidy { -namespace misc { +namespace bugprone { namespace { AST_MATCHER_P(Stmt, ignoringTemporaryExpr, @@ -79,6 +79,6 @@ void UndelegatedConstructorCheck::check( "A temporary object is created here instead"); } -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang diff --git a/clang-tools-extra/clang-tidy/misc/UndelegatedConstructor.h b/clang-tools-extra/clang-tidy/bugprone/UndelegatedConstructorCheck.h similarity index 91% rename from clang-tools-extra/clang-tidy/misc/UndelegatedConstructor.h rename to clang-tools-extra/clang-tidy/bugprone/UndelegatedConstructorCheck.h index bba36ed49bef..ed881e153675 100644 --- a/clang-tools-extra/clang-tidy/misc/UndelegatedConstructor.h +++ b/clang-tools-extra/clang-tidy/bugprone/UndelegatedConstructorCheck.h @@ -1,4 +1,4 @@ -//===--- UndelegatedConstructor.h - clang-tidy ------------------*- C++ -*-===// +//===--- UndelegatedConstructorCheck.h - clang-tidy -------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -14,7 +14,7 @@ namespace clang { namespace tidy { -namespace misc { +namespace bugprone { /// Finds creation of temporary objects in constructors that look like a /// function call to another constructor of the same class. @@ -29,7 +29,7 @@ public: void check(const ast_matchers::MatchFinder::MatchResult &Result) override; }; -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang diff --git a/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp b/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp index 89a1adaf401a..d8e9a209853f 100644 --- a/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp @@ -21,7 +21,7 @@ #include "../google/ExplicitConstructorCheck.h" #include "../misc/NewDeleteOverloadsCheck.h" #include "../misc/StaticAssertCheck.h" -#include "../misc/UndelegatedConstructor.h" +#include "../bugprone/UndelegatedConstructorCheck.h" #include "../modernize/DeprecatedHeadersCheck.h" #include "../modernize/UseAutoCheck.h" #include "../modernize/UseEmplaceCheck.h" @@ -83,7 +83,7 @@ public: CheckFactories.registerCheck( "hicpp-static-assert"); CheckFactories.registerCheck("hicpp-use-auto"); - CheckFactories.registerCheck( + CheckFactories.registerCheck( "hicpp-undelegated-constructor"); CheckFactories.registerCheck( "hicpp-use-emplace"); diff --git a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt index a4fe4fb99b28..30b8efe489e1 100644 --- a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt @@ -12,11 +12,7 @@ add_clang_library(clangTidyMiscModule SizeofContainerCheck.cpp SizeofExpressionCheck.cpp StaticAssertCheck.cpp - SuspiciousSemicolonCheck.cpp - SuspiciousStringCompareCheck.cpp - SwappedArgumentsCheck.cpp ThrowByValueCatchByReferenceCheck.cpp - UndelegatedConstructor.cpp UniqueptrResetReleaseCheck.cpp UnusedAliasDeclsCheck.cpp UnusedParametersCheck.cpp diff --git a/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp b/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp index c9f81ecbbb55..56e649276f61 100644 --- a/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp @@ -19,12 +19,8 @@ #include "SizeofContainerCheck.h" #include "SizeofExpressionCheck.h" #include "StaticAssertCheck.h" -#include "SuspiciousSemicolonCheck.h" -#include "SuspiciousStringCompareCheck.h" -#include "SwappedArgumentsCheck.h" #include "ThrowByValueCatchByReferenceCheck.h" #include "UnconventionalAssignOperatorCheck.h" -#include "UndelegatedConstructor.h" #include "UniqueptrResetReleaseCheck.h" #include "UnusedAliasDeclsCheck.h" #include "UnusedParametersCheck.h" @@ -55,16 +51,8 @@ public: CheckFactories.registerCheck( "misc-sizeof-expression"); CheckFactories.registerCheck("misc-static-assert"); - CheckFactories.registerCheck( - "misc-suspicious-semicolon"); - CheckFactories.registerCheck( - "misc-suspicious-string-compare"); - CheckFactories.registerCheck( - "misc-swapped-arguments"); CheckFactories.registerCheck( "misc-throw-by-value-catch-by-reference"); - CheckFactories.registerCheck( - "misc-undelegated-constructor"); CheckFactories.registerCheck( "misc-uniqueptr-reset-release"); CheckFactories.registerCheck( diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index 5a886241a628..ef7e74eeb1c2 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -136,6 +136,18 @@ Improvements to clang-tidy - The 'misc-suspicious-missing-comma' check was renamed to `bugprone-suspicious-missing-comma `_ +- The 'misc-suspicious-semicolon' check was renamed to `bugprone-suspicious-semicolon + `_ + +- The 'misc-suspicious-string-compare' check was renamed to `bugprone-suspicious-string-compare + `_ + +- The 'misc-swapped-arguments' check was renamed to `bugprone-swapped-arguments + `_ + +- The 'misc-undelegated-constructor' check was renamed to `bugprone-undelegated-constructor + `_ + Improvements to include-fixer ----------------------------- diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc-suspicious-semicolon.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-semicolon.rst similarity index 94% rename from clang-tools-extra/docs/clang-tidy/checks/misc-suspicious-semicolon.rst rename to clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-semicolon.rst index d38e6a6851cc..a3eb098aa9d3 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/misc-suspicious-semicolon.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-semicolon.rst @@ -1,7 +1,7 @@ -.. title:: clang-tidy - misc-suspicious-semicolon +.. title:: clang-tidy - bugprone-suspicious-semicolon -misc-suspicious-semicolon -========================= +bugprone-suspicious-semicolon +============================= Finds most instances of stray semicolons that unexpectedly alter the meaning of the code. More specifically, it looks for ``if``, ``while``, ``for`` and diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc-suspicious-string-compare.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-string-compare.rst similarity index 94% rename from clang-tools-extra/docs/clang-tidy/checks/misc-suspicious-string-compare.rst rename to clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-string-compare.rst index 9918dee2fe27..be3d2b6fbdf8 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/misc-suspicious-string-compare.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-string-compare.rst @@ -1,7 +1,7 @@ -.. title:: clang-tidy - misc-suspicious-string-compare +.. title:: clang-tidy - bugprone-suspicious-string-compare -misc-suspicious-string-compare -============================== +bugprone-suspicious-string-compare +================================== Find suspicious usage of runtime string comparison functions. This check is valid in C and C++. diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone-swapped-arguments.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone-swapped-arguments.rst new file mode 100644 index 000000000000..30ae925da24a --- /dev/null +++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone-swapped-arguments.rst @@ -0,0 +1,6 @@ +.. title:: clang-tidy - bugprone-swapped-arguments + +bugprone-swapped-arguments +========================== + +Finds potentially swapped arguments by looking at implicit conversions. diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc-undelegated-constructor.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone-undelegated-constructor.rst similarity index 63% rename from clang-tools-extra/docs/clang-tidy/checks/misc-undelegated-constructor.rst rename to clang-tools-extra/docs/clang-tidy/checks/bugprone-undelegated-constructor.rst index 3b7fffcd21f8..b32ed386f69c 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/misc-undelegated-constructor.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone-undelegated-constructor.rst @@ -1,8 +1,7 @@ -.. title:: clang-tidy - misc-undelegated-constructor - -misc-undelegated-constructor -============================ +.. title:: clang-tidy - bugprone-undelegated-constructor +bugprone-undelegated-constructor +================================ Finds creation of temporary objects in constructors that look like a function call to another constructor of the same class. diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp-undelegated-constructor.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp-undelegated-constructor.rst index 730a3069a7ec..db521c5838c6 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/hicpp-undelegated-constructor.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp-undelegated-constructor.rst @@ -1,11 +1,11 @@ .. title:: clang-tidy - hicpp-undelegated-construtor .. meta:: - :http-equiv=refresh: 5;URL=misc-undelegated-constructor.html + :http-equiv=refresh: 5;URL=bugprone-undelegated-constructor.html hicpp-undelegated-constructor ============================= -This check is an alias for `misc-undelegated-constructor `_. +This check is an alias for `bugprone-undelegated-constructor `_. Partially implements `rule 12.4.5 `_ to find misplaced constructor calls inside a constructor. diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst index 013d5c138f85..a186b4b38b23 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/list.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst @@ -40,8 +40,12 @@ Clang-Tidy Checks bugprone-suspicious-enum-usage bugprone-suspicious-memset-usage bugprone-suspicious-missing-comma + bugprone-suspicious-semicolon + bugprone-suspicious-string-compare + bugprone-swapped-arguments bugprone-throw-keyword-missing bugprone-undefined-memory-manipulation + bugprone-undelegated-constructor bugprone-use-after-move bugprone-virtual-near-miss cert-dcl03-c (redirects to misc-static-assert) @@ -121,7 +125,7 @@ Clang-Tidy Checks hicpp-signed-bitwise hicpp-special-member-functions (redirects to cppcoreguidelines-special-member-functions) hicpp-static-assert (redirects to misc-static-assert) - hicpp-undelegated-constructor (redirects to misc-undelegated-constructor) + hicpp-undelegated-constructor (redirects to bugprone-undelegated-constructor) hicpp-use-auto (redirects to modernize-use-auto) hicpp-use-emplace (redirects to modernize-use-emplace) hicpp-use-equals-default (redirects to modernize-use-equals-default) @@ -143,12 +147,8 @@ Clang-Tidy Checks misc-sizeof-container misc-sizeof-expression misc-static-assert - misc-suspicious-semicolon - misc-suspicious-string-compare - misc-swapped-arguments misc-throw-by-value-catch-by-reference misc-unconventional-assign-operator - misc-undelegated-constructor misc-uniqueptr-reset-release misc-unused-alias-decls misc-unused-parameters diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc-swapped-arguments.rst b/clang-tools-extra/docs/clang-tidy/checks/misc-swapped-arguments.rst deleted file mode 100644 index 67a604a130af..000000000000 --- a/clang-tools-extra/docs/clang-tidy/checks/misc-swapped-arguments.rst +++ /dev/null @@ -1,7 +0,0 @@ -.. title:: clang-tidy - misc-swapped-arguments - -misc-swapped-arguments -====================== - - -Finds potentially swapped arguments by looking at implicit conversions. diff --git a/clang-tools-extra/test/clang-tidy/misc-suspicious-semicolon-fail.cpp b/clang-tools-extra/test/clang-tidy/bugprone-suspicious-semicolon-fail.cpp similarity index 78% rename from clang-tools-extra/test/clang-tidy/misc-suspicious-semicolon-fail.cpp rename to clang-tools-extra/test/clang-tidy/bugprone-suspicious-semicolon-fail.cpp index e4e7ae5cf92c..db270d8c21df 100644 --- a/clang-tools-extra/test/clang-tidy/misc-suspicious-semicolon-fail.cpp +++ b/clang-tools-extra/test/clang-tidy/bugprone-suspicious-semicolon-fail.cpp @@ -1,7 +1,7 @@ -// RUN: clang-tidy %s -checks="-*,misc-suspicious-semicolon" -- -DERROR 2>&1 \ +// RUN: clang-tidy %s -checks="-*,bugprone-suspicious-semicolon" -- -DERROR 2>&1 \ // RUN: | FileCheck %s -check-prefix=CHECK-ERROR \ // RUN: -implicit-check-not="{{warning|error}}:" -// RUN: clang-tidy %s -checks="-*,misc-suspicious-semicolon,clang-diagnostic*" \ +// RUN: clang-tidy %s -checks="-*,bugprone-suspicious-semicolon,clang-diagnostic*" \ // RUN: -- -DWERROR -Wno-everything -Werror=unused-variable 2>&1 \ // RUN: | FileCheck %s -check-prefix=CHECK-WERROR \ // RUN: -implicit-check-not="{{warning|error}}:" @@ -13,7 +13,7 @@ bool g(); void f() { if (g()); - // CHECK-WERROR: :[[@LINE-1]]:11: warning: potentially unintended semicolon [misc-suspicious-semicolon] + // CHECK-WERROR: :[[@LINE-1]]:11: warning: potentially unintended semicolon [bugprone-suspicious-semicolon] #if ERROR int a // CHECK-ERROR: :[[@LINE-1]]:8: error: expected ';' at end of declaration [clang-diagnostic-error] diff --git a/clang-tools-extra/test/clang-tidy/misc-suspicious-semicolon.cpp b/clang-tools-extra/test/clang-tidy/bugprone-suspicious-semicolon.cpp similarity index 91% rename from clang-tools-extra/test/clang-tidy/misc-suspicious-semicolon.cpp rename to clang-tools-extra/test/clang-tidy/bugprone-suspicious-semicolon.cpp index 77da2c9f3a60..4f9f4c5db659 100644 --- a/clang-tools-extra/test/clang-tidy/misc-suspicious-semicolon.cpp +++ b/clang-tools-extra/test/clang-tidy/bugprone-suspicious-semicolon.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s misc-suspicious-semicolon %t +// RUN: %check_clang_tidy %s bugprone-suspicious-semicolon %t int x = 5; @@ -26,7 +26,7 @@ void correct3() void fail1() { if(x > 5); nop(); - // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: potentially unintended semicolon [misc-suspicious-semicolon] + // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: potentially unintended semicolon [bugprone-suspicious-semicolon] // CHECK-FIXES: if(x > 5) nop(); } @@ -34,7 +34,7 @@ void fail2() { if(x == 5); nop(); - // CHECK-MESSAGES: :[[@LINE-2]]:12: warning: potentially unintended semicolon [misc-suspicious-semicolon] + // CHECK-MESSAGES: :[[@LINE-2]]:12: warning: potentially unintended semicolon [bugprone-suspicious-semicolon] // CHECK-FIXES: if(x == 5){{$}} } diff --git a/clang-tools-extra/test/clang-tidy/misc-suspicious-string-compare.c b/clang-tools-extra/test/clang-tidy/bugprone-suspicious-string-compare.c similarity index 87% rename from clang-tools-extra/test/clang-tidy/misc-suspicious-string-compare.c rename to clang-tools-extra/test/clang-tidy/bugprone-suspicious-string-compare.c index d1dbf9eff9fb..3b3175ab958e 100644 --- a/clang-tools-extra/test/clang-tidy/misc-suspicious-string-compare.c +++ b/clang-tools-extra/test/clang-tidy/bugprone-suspicious-string-compare.c @@ -1,7 +1,7 @@ -// RUN: %check_clang_tidy %s misc-suspicious-string-compare %t -- \ +// RUN: %check_clang_tidy %s bugprone-suspicious-string-compare %t -- \ // RUN: -config='{CheckOptions: \ -// RUN: [{key: misc-suspicious-string-compare.WarnOnImplicitComparison, value: 1}, \ -// RUN: {key: misc-suspicious-string-compare.WarnOnLogicalNotComparison, value: 1}]}' \ +// RUN: [{key: bugprone-suspicious-string-compare.WarnOnImplicitComparison, value: 1}, \ +// RUN: {key: bugprone-suspicious-string-compare.WarnOnLogicalNotComparison, value: 1}]}' \ // RUN: -- -std=c99 static const char A[] = "abc"; @@ -11,7 +11,7 @@ int strcmp(const char *, const char *); int test_warning_patterns() { if (strcmp(A, "a")) return 0; - // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is called without explicitly comparing result [misc-suspicious-string-compare] + // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is called without explicitly comparing result [bugprone-suspicious-string-compare] // CHECK-FIXES: if (strcmp(A, "a") != 0) if (strcmp(A, "a") != 0 || diff --git a/clang-tools-extra/test/clang-tidy/misc-suspicious-string-compare.cpp b/clang-tools-extra/test/clang-tidy/bugprone-suspicious-string-compare.cpp similarity index 97% rename from clang-tools-extra/test/clang-tidy/misc-suspicious-string-compare.cpp rename to clang-tools-extra/test/clang-tidy/bugprone-suspicious-string-compare.cpp index 4c51676ded33..c1c24ffcd445 100644 --- a/clang-tools-extra/test/clang-tidy/misc-suspicious-string-compare.cpp +++ b/clang-tools-extra/test/clang-tidy/bugprone-suspicious-string-compare.cpp @@ -1,7 +1,7 @@ -// RUN: %check_clang_tidy %s misc-suspicious-string-compare %t -- \ +// RUN: %check_clang_tidy %s bugprone-suspicious-string-compare %t -- \ // RUN: -config='{CheckOptions: \ -// RUN: [{key: misc-suspicious-string-compare.WarnOnImplicitComparison, value: 1}, \ -// RUN: {key: misc-suspicious-string-compare.WarnOnLogicalNotComparison, value: 1}]}' \ +// RUN: [{key: bugprone-suspicious-string-compare.WarnOnImplicitComparison, value: 1}, \ +// RUN: {key: bugprone-suspicious-string-compare.WarnOnLogicalNotComparison, value: 1}]}' \ // RUN: -- typedef __SIZE_TYPE__ size; @@ -61,7 +61,7 @@ int _mbsnbicmp_l(const unsigned char *, const unsigned char *, size, locale_t); int test_warning_patterns() { if (strcmp(A, "a")) return 0; - // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is called without explicitly comparing result [misc-suspicious-string-compare] + // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is called without explicitly comparing result [bugprone-suspicious-string-compare] // CHECK-FIXES: if (strcmp(A, "a") != 0) if (strcmp(A, "a") == 0 || diff --git a/clang-tools-extra/test/clang-tidy/misc-swapped-arguments.cpp b/clang-tools-extra/test/clang-tidy/bugprone-swapped-arguments.cpp similarity index 97% rename from clang-tools-extra/test/clang-tidy/misc-swapped-arguments.cpp rename to clang-tools-extra/test/clang-tidy/bugprone-swapped-arguments.cpp index 4f1f0ea3d3b4..06fb2d869f69 100644 --- a/clang-tools-extra/test/clang-tidy/misc-swapped-arguments.cpp +++ b/clang-tools-extra/test/clang-tidy/bugprone-swapped-arguments.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s misc-swapped-arguments %t +// RUN: %check_clang_tidy %s bugprone-swapped-arguments %t void F(int, double); diff --git a/clang-tools-extra/test/clang-tidy/misc-undelegated-constructor-cxx98.cpp b/clang-tools-extra/test/clang-tidy/bugprone-undelegated-constructor-cxx98.cpp similarity index 76% rename from clang-tools-extra/test/clang-tidy/misc-undelegated-constructor-cxx98.cpp rename to clang-tools-extra/test/clang-tidy/bugprone-undelegated-constructor-cxx98.cpp index 78b53bb78402..f859f24dd7ba 100644 --- a/clang-tools-extra/test/clang-tidy/misc-undelegated-constructor-cxx98.cpp +++ b/clang-tools-extra/test/clang-tidy/bugprone-undelegated-constructor-cxx98.cpp @@ -1,4 +1,4 @@ -// RUN: clang-tidy %s -checks=-*,misc-undelegated-constructor -- -std=c++98 | count 0 +// RUN: clang-tidy %s -checks=-*,bugprone-undelegated-constructor -- -std=c++98 | count 0 // Note: this test expects no diagnostics, but FileCheck cannot handle that, // hence the use of | count 0. diff --git a/clang-tools-extra/test/clang-tidy/misc-undelegated-constructor.cpp b/clang-tools-extra/test/clang-tidy/bugprone-undelegated-constructor.cpp similarity index 92% rename from clang-tools-extra/test/clang-tidy/misc-undelegated-constructor.cpp rename to clang-tools-extra/test/clang-tidy/bugprone-undelegated-constructor.cpp index 1b5e3c4c641d..09b20ac74e28 100644 --- a/clang-tools-extra/test/clang-tidy/misc-undelegated-constructor.cpp +++ b/clang-tools-extra/test/clang-tidy/bugprone-undelegated-constructor.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s misc-undelegated-constructor %t +// RUN: %check_clang_tidy %s bugprone-undelegated-constructor %t struct Ctor; Ctor foo(); @@ -9,7 +9,7 @@ struct Ctor { Ctor(int, int); Ctor(Ctor *i) { Ctor(); -// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: did you intend to call a delegated constructor? A temporary object is created here instead [misc-undelegated-constructor] +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: did you intend to call a delegated constructor? A temporary object is created here instead [bugprone-undelegated-constructor] Ctor(0); // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: did you intend to call a delegated constructor? Ctor(1, 2); diff --git a/clang-tools-extra/test/clang-tidy/objc-arc-and-properties.m b/clang-tools-extra/test/clang-tidy/objc-arc-and-properties.m index 2626e8b142b5..7fbd7963b441 100644 --- a/clang-tools-extra/test/clang-tidy/objc-arc-and-properties.m +++ b/clang-tools-extra/test/clang-tidy/objc-arc-and-properties.m @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s misc-suspicious-semicolon %t +// RUN: %check_clang_tidy %s bugprone-suspicious-semicolon %t // This test checks if Objective-C 2.0 (@properties) and // Automatic Reference Counting (ARC) are enabled for .m files @@ -16,6 +16,6 @@ void fail(Foo *f) { if(f.shouldDoStuff); [f nop]; - // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: potentially unintended semicolon [misc-suspicious-semicolon] + // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: potentially unintended semicolon [bugprone-suspicious-semicolon] // CHECK-FIXES: if(f.shouldDoStuff) [f nop]; } diff --git a/clang-tools-extra/test/clang-tidy/objc-no-arc-or-properties.m b/clang-tools-extra/test/clang-tidy/objc-no-arc-or-properties.m index db8b1bf2f2f3..c1e73edeb868 100644 --- a/clang-tools-extra/test/clang-tidy/objc-no-arc-or-properties.m +++ b/clang-tools-extra/test/clang-tidy/objc-no-arc-or-properties.m @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s misc-suspicious-semicolon %t -- -- -fno-objc-arc -fobjc-abi-version=1 +// RUN: %check_clang_tidy %s bugprone-suspicious-semicolon %t -- -- -fno-objc-arc -fobjc-abi-version=1 // This test ensures check_clang_tidy.py allows disabling Objective-C ARC and // Objective-C 2.0 via passing arguments after -- on the command line. @@ -24,6 +24,6 @@ void fail(Foo *f) { if([f shouldDoStuff]); [f nop]; - // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: potentially unintended semicolon [misc-suspicious-semicolon] + // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: potentially unintended semicolon [bugprone-suspicious-semicolon] // CHECK-FIXES: if([f shouldDoStuff]) [f nop]; }