From a1a29336340080d33893f82d5bf369df11615d58 Mon Sep 17 00:00:00 2001 From: Alexander Kornienko Date: Wed, 28 Feb 2018 14:47:20 +0000 Subject: [PATCH] Rename a few checks from misc- to bugprone-. Summary: rename_check.py {misc,bugprone}-forwarding-reference-overload rename_check.py {misc,bugprone}-macro-repeated-side-effects rename_check.py {misc,bugprone}-lambda-function-name rename_check.py {misc,bugprone}-misplaced-widening-cast Reviewers: hokein, sammccall, aaron.ballman Reviewed By: aaron.ballman Subscribers: klimek, cfe-commits, mgorny Differential Revision: https://reviews.llvm.org/D43867 llvm-svn: 326327 --- clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp | 12 ++++++++++++ clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt | 4 ++++ .../{misc => bugprone}/ForwardingReferenceOverloadCheck.cpp | 4 ++-- .../{misc => bugprone}/ForwardingReferenceOverloadCheck.h | 12 ++++++------ .../{misc => bugprone}/LambdaFunctionNameCheck.cpp | 4 ++-- .../clang-tidy/{misc => bugprone}/LambdaFunctionNameCheck.h | 12 ++++++------ .../{misc => bugprone}/MacroRepeatedSideEffectsCheck.cpp | 4 ++-- .../{misc => bugprone}/MacroRepeatedSideEffectsCheck.h | 10 +++++----- .../{misc => bugprone}/MisplacedWideningCastCheck.cpp | 4 ++-- .../{misc => bugprone}/MisplacedWideningCastCheck.h | 10 +++++----- 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 ++++++++++++ ...erload.rst => bugprone-forwarding-reference-overload.rst} | 6 +++--- ...a-function-name.rst => bugprone-lambda-function-name.rst} | 6 +++--- .../checks/bugprone-macro-repeated-side-effects.rst | 7 +++++++ ...idening-cast.rst => bugprone-misplaced-widening-cast.rst} | 6 +++--- clang-tools-extra/docs/clang-tidy/checks/list.rst | 8 ++++---- .../clang-tidy/checks/misc-macro-repeated-side-effects.rst | 7 ------- ...erload.cpp => bugprone-forwarding-reference-overload.cpp} | 4 ++-- ...a-function-name.cpp => bugprone-lambda-function-name.cpp} | 12 ++++++------ ...side-effects.c => bugprone-macro-repeated-side-effects.c} | 4 ++-- ...pp => bugprone-misplaced-widening-cast-explicit-only.cpp} | 4 ++-- ...=> bugprone-misplaced-widening-cast-implicit-enabled.cpp} | 4 ++-- 24 files changed, 92 insertions(+), 80 deletions(-) rename clang-tools-extra/clang-tidy/{misc => bugprone}/ForwardingReferenceOverloadCheck.cpp (99%) rename clang-tools-extra/clang-tidy/{misc => bugprone}/ForwardingReferenceOverloadCheck.h (77%) rename clang-tools-extra/clang-tidy/{misc => bugprone}/LambdaFunctionNameCheck.cpp (98%) rename clang-tools-extra/clang-tidy/{misc => bugprone}/LambdaFunctionNameCheck.h (79%) rename clang-tools-extra/clang-tidy/{misc => bugprone}/MacroRepeatedSideEffectsCheck.cpp (99%) rename clang-tools-extra/clang-tidy/{misc => bugprone}/MacroRepeatedSideEffectsCheck.h (72%) rename clang-tools-extra/clang-tidy/{misc => bugprone}/MisplacedWideningCastCheck.cpp (99%) rename clang-tools-extra/clang-tidy/{misc => bugprone}/MisplacedWideningCastCheck.h (81%) rename clang-tools-extra/docs/clang-tidy/checks/{misc-forwarding-reference-overload.rst => bugprone-forwarding-reference-overload.rst} (92%) rename clang-tools-extra/docs/clang-tidy/checks/{misc-lambda-function-name.rst => bugprone-lambda-function-name.rst} (82%) create mode 100644 clang-tools-extra/docs/clang-tidy/checks/bugprone-macro-repeated-side-effects.rst rename clang-tools-extra/docs/clang-tidy/checks/{misc-misplaced-widening-cast.rst => bugprone-misplaced-widening-cast.rst} (92%) delete mode 100644 clang-tools-extra/docs/clang-tidy/checks/misc-macro-repeated-side-effects.rst rename clang-tools-extra/test/clang-tidy/{misc-forwarding-reference-overload.cpp => bugprone-forwarding-reference-overload.cpp} (97%) rename clang-tools-extra/test/clang-tidy/{misc-lambda-function-name.cpp => bugprone-lambda-function-name.cpp} (81%) rename clang-tools-extra/test/clang-tidy/{misc-macro-repeated-side-effects.c => bugprone-macro-repeated-side-effects.c} (96%) rename clang-tools-extra/test/clang-tidy/{misc-misplaced-widening-cast-explicit-only.cpp => bugprone-misplaced-widening-cast-explicit-only.cpp} (88%) rename clang-tools-extra/test/clang-tidy/{misc-misplaced-widening-cast-implicit-enabled.cpp => bugprone-misplaced-widening-cast-implicit-enabled.cpp} (93%) diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp index 68effd1..5e67672 100644 --- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp @@ -17,10 +17,14 @@ #include "DanglingHandleCheck.h" #include "FoldInitTypeCheck.h" #include "ForwardDeclarationNamespaceCheck.h" +#include "ForwardingReferenceOverloadCheck.h" #include "InaccurateEraseCheck.h" #include "IncorrectRoundingsCheck.h" #include "IntegerDivisionCheck.h" +#include "LambdaFunctionNameCheck.h" +#include "MacroRepeatedSideEffectsCheck.h" #include "MisplacedOperatorInStrlenInAllocCheck.h" +#include "MisplacedWideningCastCheck.h" #include "MoveForwardingReferenceCheck.h" #include "MultipleStatementMacroCheck.h" #include "StringConstructorCheck.h" @@ -51,14 +55,22 @@ public: "bugprone-fold-init-type"); CheckFactories.registerCheck( "bugprone-forward-declaration-namespace"); + CheckFactories.registerCheck( + "bugprone-forwarding-reference-overload"); CheckFactories.registerCheck( "bugprone-inaccurate-erase"); CheckFactories.registerCheck( "bugprone-incorrect-roundings"); CheckFactories.registerCheck( "bugprone-integer-division"); + CheckFactories.registerCheck( + "bugprone-lambda-function-name"); + CheckFactories.registerCheck( + "bugprone-macro-repeated-side-effects"); CheckFactories.registerCheck( "bugprone-misplaced-operator-in-strlen-in-alloc"); + CheckFactories.registerCheck( + "bugprone-misplaced-widening-cast"); CheckFactories.registerCheck( "bugprone-move-forwarding-reference"); CheckFactories.registerCheck( diff --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt index 54d93ef..73b4e55 100644 --- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt @@ -9,10 +9,14 @@ add_clang_library(clangTidyBugproneModule DanglingHandleCheck.cpp FoldInitTypeCheck.cpp ForwardDeclarationNamespaceCheck.cpp + ForwardingReferenceOverloadCheck.cpp InaccurateEraseCheck.cpp IncorrectRoundingsCheck.cpp IntegerDivisionCheck.cpp + LambdaFunctionNameCheck.cpp + MacroRepeatedSideEffectsCheck.cpp MisplacedOperatorInStrlenInAllocCheck.cpp + MisplacedWideningCastCheck.cpp MoveForwardingReferenceCheck.cpp MultipleStatementMacroCheck.cpp StringConstructorCheck.cpp diff --git a/clang-tools-extra/clang-tidy/misc/ForwardingReferenceOverloadCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp similarity index 99% rename from clang-tools-extra/clang-tidy/misc/ForwardingReferenceOverloadCheck.cpp rename to clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp index 3da5a09..17bdc76 100644 --- a/clang-tools-extra/clang-tidy/misc/ForwardingReferenceOverloadCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp @@ -16,7 +16,7 @@ using namespace clang::ast_matchers; namespace clang { namespace tidy { -namespace misc { +namespace bugprone { namespace { // Check if the given type is related to std::enable_if. @@ -143,6 +143,6 @@ void ForwardingReferenceOverloadCheck::check( } } -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang diff --git a/clang-tools-extra/clang-tidy/misc/ForwardingReferenceOverloadCheck.h b/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.h similarity index 77% rename from clang-tools-extra/clang-tidy/misc/ForwardingReferenceOverloadCheck.h rename to clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.h index ffdf0e8..4b00ab2 100644 --- a/clang-tools-extra/clang-tidy/misc/ForwardingReferenceOverloadCheck.h +++ b/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.h @@ -7,14 +7,14 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_FORWARDING_REFERENCE_OVERLOAD_H -#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_FORWARDING_REFERENCE_OVERLOAD_H +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_FORWARDINGREFERENCEOVERLOADCHECK_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_FORWARDINGREFERENCEOVERLOADCHECK_H #include "../ClangTidy.h" namespace clang { namespace tidy { -namespace misc { +namespace bugprone { /// The checker looks for constructors that can act as copy or move constructors /// through their forwarding reference parameters. If a non const lvalue @@ -26,7 +26,7 @@ namespace misc { /// C++ Design, item 26. /// /// For the user-facing documentation see: -/// http://clang.llvm.org/extra/clang-tidy/checks/misc-forwarding-reference-overload.html +/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-forwarding-reference-overload.html class ForwardingReferenceOverloadCheck : public ClangTidyCheck { public: ForwardingReferenceOverloadCheck(StringRef Name, ClangTidyContext *Context) @@ -35,8 +35,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_FORWARDING_REFERENCE_OVERLOAD_H +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_FORWARDINGREFERENCEOVERLOADCHECK_H diff --git a/clang-tools-extra/clang-tidy/misc/LambdaFunctionNameCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/LambdaFunctionNameCheck.cpp similarity index 98% rename from clang-tools-extra/clang-tidy/misc/LambdaFunctionNameCheck.cpp rename to clang-tools-extra/clang-tidy/bugprone/LambdaFunctionNameCheck.cpp index 85dad5c..60eb245 100644 --- a/clang-tools-extra/clang-tidy/misc/LambdaFunctionNameCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/LambdaFunctionNameCheck.cpp @@ -18,7 +18,7 @@ using namespace clang::ast_matchers; namespace clang { namespace tidy { -namespace misc { +namespace bugprone { namespace { @@ -94,6 +94,6 @@ void LambdaFunctionNameCheck::check(const MatchFinder::MatchResult &Result) { << PredefinedExpr::getIdentTypeName(E->getIdentType()); } -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang diff --git a/clang-tools-extra/clang-tidy/misc/LambdaFunctionNameCheck.h b/clang-tools-extra/clang-tidy/bugprone/LambdaFunctionNameCheck.h similarity index 79% rename from clang-tools-extra/clang-tidy/misc/LambdaFunctionNameCheck.h rename to clang-tools-extra/clang-tidy/bugprone/LambdaFunctionNameCheck.h index bd23b00..b7b1b44 100644 --- a/clang-tools-extra/clang-tidy/misc/LambdaFunctionNameCheck.h +++ b/clang-tools-extra/clang-tidy/bugprone/LambdaFunctionNameCheck.h @@ -7,21 +7,21 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_LAMBDA_FUNCTION_NAME_H -#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_LAMBDA_FUNCTION_NAME_H +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_LAMBDAFUNCTIONNAMECHECK_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_LAMBDAFUNCTIONNAMECHECK_H #include "../ClangTidy.h" namespace clang { namespace tidy { -namespace misc { +namespace bugprone { /// Detect when __func__ or __FUNCTION__ is being used from within a lambda. In /// that context, those expressions expand to the name of the call operator /// (i.e., `operator()`). /// /// For the user-facing documentation see: -/// http://clang.llvm.org/extra/clang-tidy/checks/misc-lambda-function-name.html +/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-lambda-function-name.html class LambdaFunctionNameCheck : public ClangTidyCheck { public: struct SourceRangeLessThan { @@ -44,8 +44,8 @@ private: SourceRangeSet SuppressMacroExpansions; }; -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang -#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_LAMBDA_FUNCTION_NAME_H +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_LAMBDAFUNCTIONNAMECHECK_H diff --git a/clang-tools-extra/clang-tidy/misc/MacroRepeatedSideEffectsCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/MacroRepeatedSideEffectsCheck.cpp similarity index 99% rename from clang-tools-extra/clang-tidy/misc/MacroRepeatedSideEffectsCheck.cpp rename to clang-tools-extra/clang-tidy/bugprone/MacroRepeatedSideEffectsCheck.cpp index 1bbed46..30c770e 100644 --- a/clang-tools-extra/clang-tidy/misc/MacroRepeatedSideEffectsCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/MacroRepeatedSideEffectsCheck.cpp @@ -15,7 +15,7 @@ namespace clang { namespace tidy { -namespace misc { +namespace bugprone { namespace { class MacroRepeatedPPCallbacks : public PPCallbacks { @@ -179,6 +179,6 @@ void MacroRepeatedSideEffectsCheck::registerPPCallbacks( *this, Compiler.getPreprocessor())); } -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang diff --git a/clang-tools-extra/clang-tidy/misc/MacroRepeatedSideEffectsCheck.h b/clang-tools-extra/clang-tidy/bugprone/MacroRepeatedSideEffectsCheck.h similarity index 72% rename from clang-tools-extra/clang-tidy/misc/MacroRepeatedSideEffectsCheck.h rename to clang-tools-extra/clang-tidy/bugprone/MacroRepeatedSideEffectsCheck.h index 10ff842..a2a3134 100644 --- a/clang-tools-extra/clang-tidy/misc/MacroRepeatedSideEffectsCheck.h +++ b/clang-tools-extra/clang-tidy/bugprone/MacroRepeatedSideEffectsCheck.h @@ -7,14 +7,14 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MACRO_REPEATED_SIDE_EFFECTS_CHECK_H -#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MACRO_REPEATED_SIDE_EFFECTS_CHECK_H +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_MACROREPEATEDSIDEEFFECTSCHECK_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_MACROREPEATEDSIDEEFFECTSCHECK_H #include "../ClangTidy.h" namespace clang { namespace tidy { -namespace misc { +namespace bugprone { /// Checks for repeated argument with side effects in macros. class MacroRepeatedSideEffectsCheck : public ClangTidyCheck { @@ -24,8 +24,8 @@ public: void registerPPCallbacks(CompilerInstance &Compiler) override; }; -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang -#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MACRO_REPEATED_SIDE_EFFECTS_CHECK_H +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_MACROREPEATEDSIDEEFFECTSCHECK_H diff --git a/clang-tools-extra/clang-tidy/misc/MisplacedWideningCastCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp similarity index 99% rename from clang-tools-extra/clang-tidy/misc/MisplacedWideningCastCheck.cpp rename to clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp index 2ba38b3..e263366 100644 --- a/clang-tools-extra/clang-tidy/misc/MisplacedWideningCastCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp @@ -16,7 +16,7 @@ using namespace clang::ast_matchers; namespace clang { namespace tidy { -namespace misc { +namespace bugprone { MisplacedWideningCastCheck::MisplacedWideningCastCheck( StringRef Name, ClangTidyContext *Context) @@ -228,6 +228,6 @@ void MisplacedWideningCastCheck::check(const MatchFinder::MatchResult &Result) { << CalcType << CastType; } -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang diff --git a/clang-tools-extra/clang-tidy/misc/MisplacedWideningCastCheck.h b/clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.h similarity index 81% rename from clang-tools-extra/clang-tidy/misc/MisplacedWideningCastCheck.h rename to clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.h index 1c3bc4a..b61556f 100644 --- a/clang-tools-extra/clang-tidy/misc/MisplacedWideningCastCheck.h +++ b/clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.h @@ -7,14 +7,14 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISPLACED_WIDENING_CAST_H -#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISPLACED_WIDENING_CAST_H +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_MISPLACEDWIDENINGCASTCHECK_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_MISPLACEDWIDENINGCASTCHECK_H #include "../ClangTidy.h" namespace clang { namespace tidy { -namespace misc { +namespace bugprone { /// Find casts of calculation results to bigger type. Typically from int to /// long. If the intention of the cast is to avoid loss of precision then @@ -27,7 +27,7 @@ namespace misc { // be the most common case. Enabled by default. /// /// For the user-facing documentation see: -/// http://clang.llvm.org/extra/clang-tidy/checks/misc-misplaced-widening-cast.html +/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-misplaced-widening-cast.html class MisplacedWideningCastCheck : public ClangTidyCheck { public: MisplacedWideningCastCheck(StringRef Name, ClangTidyContext *Context); @@ -39,7 +39,7 @@ private: const bool CheckImplicitCasts; }; -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang diff --git a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt index ecb071f..e0e9627 100644 --- a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt @@ -1,15 +1,11 @@ set(LLVM_LINK_COMPONENTS support) add_clang_library(clangTidyMiscModule - ForwardingReferenceOverloadCheck.cpp - LambdaFunctionNameCheck.cpp MisplacedConstCheck.cpp UnconventionalAssignOperatorCheck.cpp DefinitionsInHeadersCheck.cpp MacroParenthesesCheck.cpp - MacroRepeatedSideEffectsCheck.cpp MiscTidyModule.cpp - MisplacedWideningCastCheck.cpp NewDeleteOverloadsCheck.cpp NonCopyableObjects.cpp RedundantExpressionCheck.cpp diff --git a/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp b/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp index 3e25f01..4ed7c47 100644 --- a/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp @@ -11,12 +11,8 @@ #include "../ClangTidyModule.h" #include "../ClangTidyModuleRegistry.h" #include "DefinitionsInHeadersCheck.h" -#include "ForwardingReferenceOverloadCheck.h" -#include "LambdaFunctionNameCheck.h" #include "MacroParenthesesCheck.h" -#include "MacroRepeatedSideEffectsCheck.h" #include "MisplacedConstCheck.h" -#include "MisplacedWideningCastCheck.h" #include "NewDeleteOverloadsCheck.h" #include "NonCopyableObjects.h" #include "RedundantExpressionCheck.h" @@ -46,10 +42,6 @@ namespace misc { class MiscModule : public ClangTidyModule { public: void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { - CheckFactories.registerCheck( - "misc-forwarding-reference-overload"); - CheckFactories.registerCheck( - "misc-lambda-function-name"); CheckFactories.registerCheck("misc-misplaced-const"); CheckFactories.registerCheck( "misc-unconventional-assign-operator"); @@ -57,10 +49,6 @@ public: "misc-definitions-in-headers"); CheckFactories.registerCheck( "misc-macro-parentheses"); - CheckFactories.registerCheck( - "misc-macro-repeated-side-effects"); - CheckFactories.registerCheck( - "misc-misplaced-widening-cast"); CheckFactories.registerCheck( "misc-new-delete-overloads"); CheckFactories.registerCheck( diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index e6d3509..0e8ef01 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -57,6 +57,18 @@ The improvements are... Improvements to clang-tidy -------------------------- +- The 'misc-misplaced-widening-cast' check was renamed to `bugprone-misplaced-widening-cast + `_ + +- The 'misc-lambda-function-name' check was renamed to `bugprone-lambda-function-name + `_ + +- The 'misc-macro-repeated-side-effects' check was renamed to `bugprone-macro-repeated-side-effects + `_ + +- The 'misc-forwarding-reference-overload' check was renamed to `bugprone-forwarding-reference-overload + `_ + - The 'misc-incorrect-roundings' check was renamed to `bugprone-incorrect-roundings `_ diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc-forwarding-reference-overload.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone-forwarding-reference-overload.rst similarity index 92% rename from clang-tools-extra/docs/clang-tidy/checks/misc-forwarding-reference-overload.rst rename to clang-tools-extra/docs/clang-tidy/checks/bugprone-forwarding-reference-overload.rst index 1682a5f..ddf69dc 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/misc-forwarding-reference-overload.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone-forwarding-reference-overload.rst @@ -1,7 +1,7 @@ -.. title:: clang-tidy - misc-forwarding-reference-overload +.. title:: clang-tidy - bugprone-forwarding-reference-overload -misc-forwarding-reference-overload -================================== +bugprone-forwarding-reference-overload +====================================== The check looks for perfect forwarding constructors that can hide copy or move constructors. If a non const lvalue reference is passed to the constructor, the diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc-lambda-function-name.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone-lambda-function-name.rst similarity index 82% rename from clang-tools-extra/docs/clang-tidy/checks/misc-lambda-function-name.rst rename to clang-tools-extra/docs/clang-tidy/checks/bugprone-lambda-function-name.rst index 1ab584c..683977a 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/misc-lambda-function-name.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone-lambda-function-name.rst @@ -1,7 +1,7 @@ -.. title:: clang-tidy - misc-lambda-function-name +.. title:: clang-tidy - bugprone-lambda-function-name -misc-lambda-function-name -========================= +bugprone-lambda-function-name +============================= Checks for attempts to get the name of a function from within a lambda expression. The name of a lambda is always something like ``operator()``, which diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone-macro-repeated-side-effects.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone-macro-repeated-side-effects.rst new file mode 100644 index 0000000..15dfdca --- /dev/null +++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone-macro-repeated-side-effects.rst @@ -0,0 +1,7 @@ +.. title:: clang-tidy - bugprone-macro-repeated-side-effects + +bugprone-macro-repeated-side-effects +==================================== + + +Checks for repeated argument with side effects in macros. diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc-misplaced-widening-cast.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone-misplaced-widening-cast.rst similarity index 92% rename from clang-tools-extra/docs/clang-tidy/checks/misc-misplaced-widening-cast.rst rename to clang-tools-extra/docs/clang-tidy/checks/bugprone-misplaced-widening-cast.rst index a2fc2bf..f42be76 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/misc-misplaced-widening-cast.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone-misplaced-widening-cast.rst @@ -1,7 +1,7 @@ -.. title:: clang-tidy - misc-misplaced-widening-cast +.. title:: clang-tidy - bugprone-misplaced-widening-cast -misc-misplaced-widening-cast -============================ +bugprone-misplaced-widening-cast +================================ This check will warn when there is a cast of a calculation result to a bigger type. If the intention of the cast is to avoid loss of precision then the cast diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst index f50fd71..a632f5d 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/list.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst @@ -24,10 +24,14 @@ Clang-Tidy Checks bugprone-dangling-handle bugprone-fold-init-type bugprone-forward-declaration-namespace + bugprone-forwarding-reference-overload bugprone-inaccurate-erase bugprone-incorrect-roundings bugprone-integer-division + bugprone-lambda-function-name + bugprone-macro-repeated-side-effects bugprone-misplaced-operator-in-strlen-in-alloc + bugprone-misplaced-widening-cast bugprone-move-forwarding-reference bugprone-multiple-statement-macro bugprone-string-constructor @@ -127,12 +131,8 @@ Clang-Tidy Checks llvm-namespace-comment llvm-twine-local misc-definitions-in-headers - misc-forwarding-reference-overload - misc-lambda-function-name misc-macro-parentheses - misc-macro-repeated-side-effects misc-misplaced-const - misc-misplaced-widening-cast misc-new-delete-overloads misc-non-copyable-objects misc-redundant-expression diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc-macro-repeated-side-effects.rst b/clang-tools-extra/docs/clang-tidy/checks/misc-macro-repeated-side-effects.rst deleted file mode 100644 index 7cd3781..0000000 --- a/clang-tools-extra/docs/clang-tidy/checks/misc-macro-repeated-side-effects.rst +++ /dev/null @@ -1,7 +0,0 @@ -.. title:: clang-tidy - misc-macro-repeated-side-effects - -misc-macro-repeated-side-effects -================================ - - -Checks for repeated argument with side effects in macros. diff --git a/clang-tools-extra/test/clang-tidy/misc-forwarding-reference-overload.cpp b/clang-tools-extra/test/clang-tidy/bugprone-forwarding-reference-overload.cpp similarity index 97% rename from clang-tools-extra/test/clang-tidy/misc-forwarding-reference-overload.cpp rename to clang-tools-extra/test/clang-tidy/bugprone-forwarding-reference-overload.cpp index a309466..3510685 100644 --- a/clang-tools-extra/test/clang-tidy/misc-forwarding-reference-overload.cpp +++ b/clang-tools-extra/test/clang-tidy/bugprone-forwarding-reference-overload.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s misc-forwarding-reference-overload %t -- -- -std=c++14 +// RUN: %check_clang_tidy %s bugprone-forwarding-reference-overload %t -- -- -std=c++14 namespace std { template struct enable_if { typedef T type; }; @@ -20,7 +20,7 @@ template constexpr bool just_true = true; class Test1 { public: template Test1(T &&n); - // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: constructor accepting a forwarding reference can hide the copy and move constructors [misc-forwarding-reference-overload] + // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: constructor accepting a forwarding reference can hide the copy and move constructors [bugprone-forwarding-reference-overload] template Test1(T &&n, int i = 5, ...); // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: constructor accepting a forwarding reference can hide the copy and move constructors diff --git a/clang-tools-extra/test/clang-tidy/misc-lambda-function-name.cpp b/clang-tools-extra/test/clang-tidy/bugprone-lambda-function-name.cpp similarity index 81% rename from clang-tools-extra/test/clang-tidy/misc-lambda-function-name.cpp rename to clang-tools-extra/test/clang-tidy/bugprone-lambda-function-name.cpp index cc5aa2b..145928b 100644 --- a/clang-tools-extra/test/clang-tidy/misc-lambda-function-name.cpp +++ b/clang-tools-extra/test/clang-tidy/bugprone-lambda-function-name.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s misc-lambda-function-name %t +// RUN: %check_clang_tidy %s bugprone-lambda-function-name %t void Foo(const char* a, const char* b, int c) {} @@ -8,15 +8,15 @@ void Foo(const char* a, const char* b, int c) {} void Positives() { [] { __func__; }(); - // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [misc-lambda-function-name] + // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name] [] { __FUNCTION__; }(); - // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__FUNCTION__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [misc-lambda-function-name] + // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__FUNCTION__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name] [] { FUNC_MACRO; }(); - // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [misc-lambda-function-name] + // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name] [] { FUNCTION_MACRO; }(); - // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__FUNCTION__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [misc-lambda-function-name] + // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__FUNCTION__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name] [] { EMBED_IN_ANOTHER_MACRO1; }(); - // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [misc-lambda-function-name] + // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name] } #define FUNC_MACRO_WITH_FILE_AND_LINE Foo(__func__, __FILE__, __LINE__) diff --git a/clang-tools-extra/test/clang-tidy/misc-macro-repeated-side-effects.c b/clang-tools-extra/test/clang-tidy/bugprone-macro-repeated-side-effects.c similarity index 96% rename from clang-tools-extra/test/clang-tidy/misc-macro-repeated-side-effects.c rename to clang-tools-extra/test/clang-tidy/bugprone-macro-repeated-side-effects.c index 7b01cc6..bcea47a 100644 --- a/clang-tools-extra/test/clang-tidy/misc-macro-repeated-side-effects.c +++ b/clang-tools-extra/test/clang-tidy/bugprone-macro-repeated-side-effects.c @@ -1,9 +1,9 @@ -// RUN: %check_clang_tidy %s misc-macro-repeated-side-effects %t +// RUN: %check_clang_tidy %s bugprone-macro-repeated-side-effects %t #define badA(x,y) ((x)+((x)+(y))+(y)) void bad(int ret, int a, int b) { ret = badA(a++, b); - // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: side effects in the 1st macro argument 'x' are repeated in macro expansion [misc-macro-repeated-side-effects] + // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: side effects in the 1st macro argument 'x' are repeated in macro expansion [bugprone-macro-repeated-side-effects] ret = badA(++a, b); // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: side effects in the 1st macro argument 'x' ret = badA(a--, b); diff --git a/clang-tools-extra/test/clang-tidy/misc-misplaced-widening-cast-explicit-only.cpp b/clang-tools-extra/test/clang-tidy/bugprone-misplaced-widening-cast-explicit-only.cpp similarity index 88% rename from clang-tools-extra/test/clang-tidy/misc-misplaced-widening-cast-explicit-only.cpp rename to clang-tools-extra/test/clang-tidy/bugprone-misplaced-widening-cast-explicit-only.cpp index dc66335..be12614 100644 --- a/clang-tools-extra/test/clang-tidy/misc-misplaced-widening-cast-explicit-only.cpp +++ b/clang-tools-extra/test/clang-tidy/bugprone-misplaced-widening-cast-explicit-only.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s misc-misplaced-widening-cast %t -- -config="{CheckOptions: [{key: misc-misplaced-widening-cast.CheckImplicitCasts, value: 0}]}" -- +// RUN: %check_clang_tidy %s bugprone-misplaced-widening-cast %t -- -config="{CheckOptions: [{key: bugprone-misplaced-widening-cast.CheckImplicitCasts, value: 0}]}" -- void func(long arg) {} @@ -7,7 +7,7 @@ void assign(int a, int b) { l = a * b; l = (long)(a * b); - // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long' is ineffective, or there is loss of precision before the conversion [misc-misplaced-widening-cast] + // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long' is ineffective, or there is loss of precision before the conversion [bugprone-misplaced-widening-cast] l = (long)a * b; l = a << 8; diff --git a/clang-tools-extra/test/clang-tidy/misc-misplaced-widening-cast-implicit-enabled.cpp b/clang-tools-extra/test/clang-tidy/bugprone-misplaced-widening-cast-implicit-enabled.cpp similarity index 93% rename from clang-tools-extra/test/clang-tidy/misc-misplaced-widening-cast-implicit-enabled.cpp rename to clang-tools-extra/test/clang-tidy/bugprone-misplaced-widening-cast-implicit-enabled.cpp index 9e7cd81..5487b33 100644 --- a/clang-tools-extra/test/clang-tidy/misc-misplaced-widening-cast-implicit-enabled.cpp +++ b/clang-tools-extra/test/clang-tidy/bugprone-misplaced-widening-cast-implicit-enabled.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s misc-misplaced-widening-cast %t -- -config="{CheckOptions: [{key: misc-misplaced-widening-cast.CheckImplicitCasts, value: 1}]}" -- +// RUN: %check_clang_tidy %s bugprone-misplaced-widening-cast %t -- -config="{CheckOptions: [{key: bugprone-misplaced-widening-cast.CheckImplicitCasts, value: 1}]}" -- void func(long arg) {} @@ -6,7 +6,7 @@ void assign(int a, int b) { long l; l = a * b; - // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long' is ineffective, or there is loss of precision before the conversion [misc-misplaced-widening-cast] + // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long' is ineffective, or there is loss of precision before the conversion [bugprone-misplaced-widening-cast] l = (long)(a * b); // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long' l = (long)a * b; -- 2.7.4