Index: clang-tidy/bugprone/AssertSideEffectCheck.h =================================================================== --- clang-tidy/bugprone/AssertSideEffectCheck.h +++ clang-tidy/bugprone/AssertSideEffectCheck.h @@ -17,7 +17,7 @@ namespace clang { namespace tidy { -namespace misc { +namespace bugprone { /// Finds `assert()` with side effect. /// @@ -45,7 +45,7 @@ SmallVector AssertMacros; }; -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang Index: clang-tidy/bugprone/AssertSideEffectCheck.cpp =================================================================== --- clang-tidy/bugprone/AssertSideEffectCheck.cpp +++ clang-tidy/bugprone/AssertSideEffectCheck.cpp @@ -22,7 +22,7 @@ namespace clang { namespace tidy { -namespace misc { +namespace bugprone { namespace { @@ -122,6 +122,6 @@ diag(Loc, "found %0() with side effect") << AssertMacroName; } -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang Index: clang-tidy/bugprone/BoolPointerImplicitConversionCheck.h =================================================================== --- clang-tidy/bugprone/BoolPointerImplicitConversionCheck.h +++ clang-tidy/bugprone/BoolPointerImplicitConversionCheck.h @@ -14,7 +14,7 @@ namespace clang { namespace tidy { -namespace misc { +namespace bugprone { /// Checks for conditions based on implicit conversion from a bool pointer to /// bool. @@ -35,7 +35,7 @@ void check(const ast_matchers::MatchFinder::MatchResult &Result) override; }; -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang Index: clang-tidy/bugprone/BoolPointerImplicitConversionCheck.cpp =================================================================== --- clang-tidy/bugprone/BoolPointerImplicitConversionCheck.cpp +++ clang-tidy/bugprone/BoolPointerImplicitConversionCheck.cpp @@ -13,7 +13,7 @@ namespace clang { namespace tidy { -namespace misc { +namespace bugprone { void BoolPointerImplicitConversionCheck::registerMatchers(MatchFinder *Finder) { // Look for ifs that have an implicit bool* to bool conversion in the @@ -68,6 +68,6 @@ << FixItHint::CreateInsertion(Var->getLocStart(), "*"); } -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang Index: clang-tidy/bugprone/BugproneTidyModule.cpp =================================================================== --- clang-tidy/bugprone/BugproneTidyModule.cpp +++ clang-tidy/bugprone/BugproneTidyModule.cpp @@ -11,13 +11,22 @@ #include "../ClangTidyModule.h" #include "../ClangTidyModuleRegistry.h" #include "ArgumentCommentCheck.h" +#include "AssertSideEffectCheck.h" +#include "BoolPointerImplicitConversionCheck.h" #include "CopyConstructorInitCheck.h" #include "DanglingHandleCheck.h" +#include "FoldInitTypeCheck.h" +#include "ForwardDeclarationNamespaceCheck.h" +#include "InaccurateEraseCheck.h" #include "IntegerDivisionCheck.h" #include "MisplacedOperatorInStrlenInAllocCheck.h" +#include "MoveForwardingReferenceCheck.h" +#include "MultipleStatementMacroCheck.h" #include "StringConstructorCheck.h" #include "SuspiciousMemsetUsageCheck.h" #include "UndefinedMemoryManipulationCheck.h" +#include "UseAfterMoveCheck.h" +#include "VirtualNearMissCheck.h" namespace clang { namespace tidy { @@ -28,20 +37,38 @@ void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { CheckFactories.registerCheck( "bugprone-argument-comment"); + CheckFactories.registerCheck( + "bugprone-assert-side-effect"); + CheckFactories.registerCheck( + "bugprone-bool-pointer-implicit-conversion"); CheckFactories.registerCheck( "bugprone-copy-constructor-init"); CheckFactories.registerCheck( "bugprone-dangling-handle"); + CheckFactories.registerCheck( + "bugprone-fold-init-type"); + CheckFactories.registerCheck( + "bugprone-forward-declaration-namespace"); + CheckFactories.registerCheck( + "bugprone-inaccurate-erase"); CheckFactories.registerCheck( "bugprone-integer-division"); CheckFactories.registerCheck( "bugprone-misplaced-operator-in-strlen-in-alloc"); + CheckFactories.registerCheck( + "bugprone-move-forwarding-reference"); + CheckFactories.registerCheck( + "bugprone-multiple-statement-macro"); CheckFactories.registerCheck( "bugprone-string-constructor"); CheckFactories.registerCheck( "bugprone-suspicious-memset-usage"); CheckFactories.registerCheck( "bugprone-undefined-memory-manipulation"); + CheckFactories.registerCheck( + "bugprone-use-after-move"); + CheckFactories.registerCheck( + "bugprone-virtual-near-miss"); } }; Index: clang-tidy/bugprone/CMakeLists.txt =================================================================== --- clang-tidy/bugprone/CMakeLists.txt +++ clang-tidy/bugprone/CMakeLists.txt @@ -2,14 +2,23 @@ add_clang_library(clangTidyBugproneModule ArgumentCommentCheck.cpp + AssertSideEffectCheck.cpp + BoolPointerImplicitConversionCheck.cpp BugproneTidyModule.cpp CopyConstructorInitCheck.cpp DanglingHandleCheck.cpp + FoldInitTypeCheck.cpp + ForwardDeclarationNamespaceCheck.cpp + InaccurateEraseCheck.cpp IntegerDivisionCheck.cpp MisplacedOperatorInStrlenInAllocCheck.cpp + MoveForwardingReferenceCheck.cpp + MultipleStatementMacroCheck.cpp StringConstructorCheck.cpp SuspiciousMemsetUsageCheck.cpp UndefinedMemoryManipulationCheck.cpp + UseAfterMoveCheck.cpp + VirtualNearMissCheck.cpp LINK_LIBS clangAnalysis Index: clang-tidy/bugprone/FoldInitTypeCheck.h =================================================================== --- clang-tidy/bugprone/FoldInitTypeCheck.h +++ clang-tidy/bugprone/FoldInitTypeCheck.h @@ -7,14 +7,14 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_FOLD_INIT_TYPE_H -#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_FOLD_INIT_TYPE_H +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_FOLD_INIT_TYPE_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_FOLD_INIT_TYPE_H #include "../ClangTidy.h" namespace clang { namespace tidy { -namespace misc { +namespace bugprone { /// Find and flag invalid initializer values in folds, e.g. std::accumulate. /// Example: @@ -24,7 +24,7 @@ /// \endcode /// /// For the user-facing documentation see: -/// http://clang.llvm.org/extra/clang-tidy/checks/misc-fold-init-type.html +/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-fold-init-type.html class FoldInitTypeCheck : public ClangTidyCheck { public: FoldInitTypeCheck(StringRef Name, ClangTidyContext *Context) @@ -37,8 +37,8 @@ const ASTContext &Context, const CallExpr &CallNode); }; -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang -#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_FOLD_INIT_TYPE_H +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_FOLD_INIT_TYPE_H Index: clang-tidy/bugprone/FoldInitTypeCheck.cpp =================================================================== --- clang-tidy/bugprone/FoldInitTypeCheck.cpp +++ clang-tidy/bugprone/FoldInitTypeCheck.cpp @@ -15,7 +15,7 @@ namespace clang { namespace tidy { -namespace misc { +namespace bugprone { void FoldInitTypeCheck::registerMatchers(MatchFinder *Finder) { // We match functions of interest and bind the iterator and init value types. @@ -135,6 +135,6 @@ doCheck(*Iter2ValueType, *InitType, *Result.Context, *CallNode); } -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang Index: clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.h =================================================================== --- clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.h +++ clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.h @@ -17,7 +17,7 @@ namespace clang { namespace tidy { -namespace misc { +namespace bugprone { /// Checks if an unused forward declaration is in a wrong namespace. /// @@ -37,7 +37,7 @@ /// point. /// /// For the user-facing documentation see: -/// http://clang.llvm.org/extra/clang-tidy/checks/misc-forward-declaration-namespace.html +/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-forward-declaration-namespace.html class ForwardDeclarationNamespaceCheck : public ClangTidyCheck { public: ForwardDeclarationNamespaceCheck(StringRef Name, ClangTidyContext *Context) @@ -52,7 +52,7 @@ llvm::SmallPtrSet FriendTypes; }; -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang Index: clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.cpp =================================================================== --- clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.cpp +++ clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.cpp @@ -19,7 +19,7 @@ namespace clang { namespace tidy { -namespace misc { +namespace bugprone { void ForwardDeclarationNamespaceCheck::registerMatchers(MatchFinder *Finder) { // Match all class declarations/definitions *EXCEPT* @@ -169,6 +169,6 @@ } } -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang Index: clang-tidy/bugprone/InaccurateEraseCheck.h =================================================================== --- clang-tidy/bugprone/InaccurateEraseCheck.h +++ clang-tidy/bugprone/InaccurateEraseCheck.h @@ -14,7 +14,7 @@ namespace clang { namespace tidy { -namespace misc { +namespace bugprone { /// Checks for inaccurate use of the `erase()` method. /// @@ -31,7 +31,7 @@ void check(const ast_matchers::MatchFinder::MatchResult &Result) override; }; -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang Index: clang-tidy/bugprone/InaccurateEraseCheck.cpp =================================================================== --- clang-tidy/bugprone/InaccurateEraseCheck.cpp +++ clang-tidy/bugprone/InaccurateEraseCheck.cpp @@ -16,7 +16,7 @@ namespace clang { namespace tidy { -namespace misc { +namespace bugprone { namespace { AST_MATCHER(Decl, isInStdNamespace) { return Node.isInStdNamespace(); } @@ -76,6 +76,6 @@ << Hint; } -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang Index: clang-tidy/bugprone/MoveForwardingReferenceCheck.h =================================================================== --- clang-tidy/bugprone/MoveForwardingReferenceCheck.h +++ clang-tidy/bugprone/MoveForwardingReferenceCheck.h @@ -14,7 +14,7 @@ namespace clang { namespace tidy { -namespace misc { +namespace bugprone { /// The check warns if std::move is applied to a forwarding reference (i.e. an /// rvalue reference of a function template argument type). @@ -33,7 +33,7 @@ /// The check suggests replacing the std::move with a std::forward. /// /// For the user-facing documentation see: -/// http://clang.llvm.org/extra/clang-tidy/checks/misc-move-forwarding-reference.html +/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-move-forwarding-reference.html class MoveForwardingReferenceCheck : public ClangTidyCheck { public: MoveForwardingReferenceCheck(StringRef Name, ClangTidyContext *Context) @@ -42,7 +42,7 @@ void check(const ast_matchers::MatchFinder::MatchResult &Result) override; }; -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang Index: clang-tidy/bugprone/MoveForwardingReferenceCheck.cpp =================================================================== --- clang-tidy/bugprone/MoveForwardingReferenceCheck.cpp +++ clang-tidy/bugprone/MoveForwardingReferenceCheck.cpp @@ -17,7 +17,7 @@ namespace clang { namespace tidy { -namespace misc { +namespace bugprone { static void replaceMoveWithForward(const UnresolvedLookupExpr *Callee, const ParmVarDecl *ParmVar, @@ -128,6 +128,6 @@ *Result.Context); } -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang Index: clang-tidy/bugprone/MultipleStatementMacroCheck.h =================================================================== --- clang-tidy/bugprone/MultipleStatementMacroCheck.h +++ clang-tidy/bugprone/MultipleStatementMacroCheck.h @@ -7,21 +7,21 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MULTIPLE_STATEMENT_MACRO_H -#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MULTIPLE_STATEMENT_MACRO_H +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_MULTIPLE_STATEMENT_MACRO_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_MULTIPLE_STATEMENT_MACRO_H #include "../ClangTidy.h" namespace clang { namespace tidy { -namespace misc { +namespace bugprone { /// Detect multiple statement macros that are used in unbraced conditionals. /// Only the first statement of the macro will be inside the conditional and the /// other ones will be executed unconditionally. /// /// For the user-facing documentation see: -/// http://clang.llvm.org/extra/clang-tidy/checks/misc-multiple-statement-macro.html +/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-multiple-statement-macro.html class MultipleStatementMacroCheck : public ClangTidyCheck { public: MultipleStatementMacroCheck(StringRef Name, ClangTidyContext *Context) @@ -30,8 +30,8 @@ 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_MULTIPLE_STATEMENT_MACRO_H +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_MULTIPLE_STATEMENT_MACRO_H Index: clang-tidy/bugprone/MultipleStatementMacroCheck.cpp =================================================================== --- clang-tidy/bugprone/MultipleStatementMacroCheck.cpp +++ clang-tidy/bugprone/MultipleStatementMacroCheck.cpp @@ -15,7 +15,7 @@ namespace clang { namespace tidy { -namespace misc { +namespace bugprone { namespace { @@ -101,6 +101,6 @@ "unconditionally executed"); } -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang Index: clang-tidy/bugprone/UseAfterMoveCheck.h =================================================================== --- clang-tidy/bugprone/UseAfterMoveCheck.h +++ clang-tidy/bugprone/UseAfterMoveCheck.h @@ -14,13 +14,13 @@ namespace clang { namespace tidy { -namespace misc { +namespace bugprone { /// The check warns if an object is used after it has been moved, without an /// intervening reinitialization. /// /// For details, see the user-facing documentation: -/// http://clang.llvm.org/extra/clang-tidy/checks/misc-use-after-move.html +/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-use-after-move.html class UseAfterMoveCheck : public ClangTidyCheck { public: UseAfterMoveCheck(StringRef Name, ClangTidyContext *Context) @@ -29,7 +29,7 @@ void check(const ast_matchers::MatchFinder::MatchResult &Result) override; }; -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang Index: clang-tidy/bugprone/UseAfterMoveCheck.cpp =================================================================== --- clang-tidy/bugprone/UseAfterMoveCheck.cpp +++ clang-tidy/bugprone/UseAfterMoveCheck.cpp @@ -20,7 +20,7 @@ namespace clang { namespace tidy { -namespace misc { +namespace bugprone { namespace { @@ -429,6 +429,6 @@ emitDiagnostic(MovingCall, Arg, Use, this, Result.Context); } -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang Index: clang-tidy/bugprone/VirtualNearMissCheck.h =================================================================== --- clang-tidy/bugprone/VirtualNearMissCheck.h +++ clang-tidy/bugprone/VirtualNearMissCheck.h @@ -7,15 +7,15 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_VIRTUAL_NEAR_MISS_H -#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_VIRTUAL_NEAR_MISS_H +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_VIRTUAL_NEAR_MISS_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_VIRTUAL_NEAR_MISS_H #include "../ClangTidy.h" #include "llvm/ADT/DenseMap.h" namespace clang { namespace tidy { -namespace misc { +namespace bugprone { /// \brief Checks for near miss of virtual methods. /// @@ -23,7 +23,7 @@ /// very similar name and an identical signature defined in a base class. /// /// For the user-facing documentation see: -/// http://clang.llvm.org/extra/clang-tidy/checks/misc-virtual-near-miss.html +/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-virtual-near-miss.html class VirtualNearMissCheck : public ClangTidyCheck { public: VirtualNearMissCheck(StringRef Name, ClangTidyContext *Context) @@ -58,8 +58,8 @@ const unsigned EditDistanceThreshold = 1; }; -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang -#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_VIRTUAL_NEAR_MISS_H +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_VIRTUAL_NEAR_MISS_H Index: clang-tidy/bugprone/VirtualNearMissCheck.cpp =================================================================== --- clang-tidy/bugprone/VirtualNearMissCheck.cpp +++ clang-tidy/bugprone/VirtualNearMissCheck.cpp @@ -17,7 +17,7 @@ namespace clang { namespace tidy { -namespace misc { +namespace bugprone { AST_MATCHER(CXXMethodDecl, isStatic) { return Node.isStatic(); } @@ -269,6 +269,6 @@ } } -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang Index: clang-tidy/hicpp/HICPPTidyModule.cpp =================================================================== --- clang-tidy/hicpp/HICPPTidyModule.cpp +++ clang-tidy/hicpp/HICPPTidyModule.cpp @@ -10,6 +10,7 @@ #include "../ClangTidy.h" #include "../ClangTidyModule.h" #include "../ClangTidyModuleRegistry.h" +#include "../bugprone/UseAfterMoveCheck.h" #include "../cppcoreguidelines/NoMallocCheck.h" #include "../cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.h" #include "../cppcoreguidelines/ProTypeMemberInitCheck.h" @@ -22,7 +23,6 @@ #include "../misc/NoexceptMoveConstructorCheck.h" #include "../misc/StaticAssertCheck.h" #include "../misc/UndelegatedConstructor.h" -#include "../misc/UseAfterMoveCheck.h" #include "../modernize/DeprecatedHeadersCheck.h" #include "../modernize/UseAutoCheck.h" #include "../modernize/UseEmplaceCheck.h" @@ -59,7 +59,7 @@ "hicpp-function-size"); CheckFactories.registerCheck( "hicpp-named-parameter"); - CheckFactories.registerCheck( + CheckFactories.registerCheck( "hicpp-invalid-access-moved"); CheckFactories.registerCheck( "hicpp-member-init"); Index: clang-tidy/misc/CMakeLists.txt =================================================================== --- clang-tidy/misc/CMakeLists.txt +++ clang-tidy/misc/CMakeLists.txt @@ -1,16 +1,11 @@ set(LLVM_LINK_COMPONENTS support) add_clang_library(clangTidyMiscModule - AssertSideEffectCheck.cpp ForwardingReferenceOverloadCheck.cpp LambdaFunctionNameCheck.cpp MisplacedConstCheck.cpp UnconventionalAssignOperatorCheck.cpp - BoolPointerImplicitConversionCheck.cpp DefinitionsInHeadersCheck.cpp - FoldInitTypeCheck.cpp - ForwardDeclarationNamespaceCheck.cpp - InaccurateEraseCheck.cpp IncorrectRoundings.cpp InefficientAlgorithmCheck.cpp MacroParenthesesCheck.cpp @@ -19,8 +14,6 @@ MisplacedWideningCastCheck.cpp MoveConstantArgumentCheck.cpp MoveConstructorInitCheck.cpp - MoveForwardingReferenceCheck.cpp - MultipleStatementMacroCheck.cpp NewDeleteOverloadsCheck.cpp NoexceptMoveConstructorCheck.cpp NonCopyableObjects.cpp @@ -43,8 +36,6 @@ UnusedParametersCheck.cpp UnusedRAIICheck.cpp UnusedUsingDeclsCheck.cpp - UseAfterMoveCheck.cpp - VirtualNearMissCheck.cpp LINK_LIBS clangAnalysis Index: clang-tidy/misc/MiscTidyModule.cpp =================================================================== --- clang-tidy/misc/MiscTidyModule.cpp +++ clang-tidy/misc/MiscTidyModule.cpp @@ -10,13 +10,8 @@ #include "../ClangTidy.h" #include "../ClangTidyModule.h" #include "../ClangTidyModuleRegistry.h" -#include "AssertSideEffectCheck.h" -#include "BoolPointerImplicitConversionCheck.h" #include "DefinitionsInHeadersCheck.h" -#include "FoldInitTypeCheck.h" -#include "ForwardDeclarationNamespaceCheck.h" #include "ForwardingReferenceOverloadCheck.h" -#include "InaccurateEraseCheck.h" #include "IncorrectRoundings.h" #include "InefficientAlgorithmCheck.h" #include "LambdaFunctionNameCheck.h" @@ -26,8 +21,6 @@ #include "MisplacedWideningCastCheck.h" #include "MoveConstantArgumentCheck.h" #include "MoveConstructorInitCheck.h" -#include "MoveForwardingReferenceCheck.h" -#include "MultipleStatementMacroCheck.h" #include "NewDeleteOverloadsCheck.h" #include "NoexceptMoveConstructorCheck.h" #include "NonCopyableObjects.h" @@ -51,8 +44,6 @@ #include "UnusedParametersCheck.h" #include "UnusedRAIICheck.h" #include "UnusedUsingDeclsCheck.h" -#include "UseAfterMoveCheck.h" -#include "VirtualNearMissCheck.h" namespace clang { namespace tidy { @@ -61,8 +52,6 @@ class MiscModule : public ClangTidyModule { public: void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { - CheckFactories.registerCheck( - "misc-assert-side-effect"); CheckFactories.registerCheck( "misc-forwarding-reference-overload"); CheckFactories.registerCheck( @@ -70,14 +59,8 @@ CheckFactories.registerCheck("misc-misplaced-const"); CheckFactories.registerCheck( "misc-unconventional-assign-operator"); - CheckFactories.registerCheck( - "misc-bool-pointer-implicit-conversion"); CheckFactories.registerCheck( "misc-definitions-in-headers"); - CheckFactories.registerCheck("misc-fold-init-type"); - CheckFactories.registerCheck( - "misc-forward-declaration-namespace"); - CheckFactories.registerCheck("misc-inaccurate-erase"); CheckFactories.registerCheck( "misc-incorrect-roundings"); CheckFactories.registerCheck( @@ -92,10 +75,6 @@ "misc-move-const-arg"); CheckFactories.registerCheck( "misc-move-constructor-init"); - CheckFactories.registerCheck( - "misc-move-forwarding-reference"); - CheckFactories.registerCheck( - "misc-multiple-statement-macro"); CheckFactories.registerCheck( "misc-new-delete-overloads"); CheckFactories.registerCheck( @@ -136,9 +115,6 @@ CheckFactories.registerCheck("misc-unused-raii"); CheckFactories.registerCheck( "misc-unused-using-decls"); - CheckFactories.registerCheck("misc-use-after-move"); - CheckFactories.registerCheck( - "misc-virtual-near-miss"); } }; Index: docs/ReleaseNotes.rst =================================================================== --- docs/ReleaseNotes.rst +++ docs/ReleaseNotes.rst @@ -57,6 +57,33 @@ Improvements to clang-tidy -------------------------- +- The 'misc-virtual-near-miss' check was renamed to `bugprone-virtual-near-miss + `_ + +- The 'misc-use-after-move' check was renamed to `bugprone-use-after-move + `_ + +- The 'misc-multiple-statement-macro' check was renamed to `bugprone-multiple-statement-macro + `_ + +- The 'misc-move-forwarding-reference' check was renamed to `bugprone-move-forwarding-reference + `_ + +- The 'misc-inaccurate-erase' check was renamed to `bugprone-inaccurate-erase + `_ + +- The 'misc-forward-declaration-namespace' check was renamed to `bugprone-forward-declaration-namespace + `_ + +- The 'misc-fold-init-type' check was renamed to `bugprone-fold-init-type + `_ + +- The 'misc-bool-pointer-implicit-conversion' check was renamed to `bugprone-bool-pointer-implicit-conversion + `_ + +- The 'misc-assert-side-effect' check was renamed to `bugprone-assert-side-effect + `_ + - The 'misc-dangling-handle' check was renamed to `bugprone-dangling-handle `_ Index: docs/clang-tidy/checks/bugprone-assert-side-effect.rst =================================================================== --- docs/clang-tidy/checks/bugprone-assert-side-effect.rst +++ docs/clang-tidy/checks/bugprone-assert-side-effect.rst @@ -1,7 +1,7 @@ -.. title:: clang-tidy - misc-assert-side-effect +.. title:: clang-tidy - bugprone-assert-side-effect -misc-assert-side-effect -======================= +bugprone-assert-side-effect +=========================== Finds ``assert()`` with side effect. Index: docs/clang-tidy/checks/bugprone-bool-pointer-implicit-conversion.rst =================================================================== --- docs/clang-tidy/checks/bugprone-bool-pointer-implicit-conversion.rst +++ docs/clang-tidy/checks/bugprone-bool-pointer-implicit-conversion.rst @@ -1,7 +1,7 @@ -.. title:: clang-tidy - misc-bool-pointer-implicit-conversion +.. title:: clang-tidy - bugprone-bool-pointer-implicit-conversion -misc-bool-pointer-implicit-conversion -===================================== +bugprone-bool-pointer-implicit-conversion +========================================= Checks for conditions based on implicit conversion from a ``bool`` pointer to ``bool``. Index: docs/clang-tidy/checks/bugprone-fold-init-type.rst =================================================================== --- docs/clang-tidy/checks/bugprone-fold-init-type.rst +++ docs/clang-tidy/checks/bugprone-fold-init-type.rst @@ -1,7 +1,7 @@ -.. title:: clang-tidy - misc-fold-init-type +.. title:: clang-tidy - bugprone-fold-init-type -misc-fold-init-type -=================== +bugprone-fold-init-type +======================= The check flags type mismatches in `folds `_ Index: docs/clang-tidy/checks/bugprone-forward-declaration-namespace.rst =================================================================== --- docs/clang-tidy/checks/bugprone-forward-declaration-namespace.rst +++ docs/clang-tidy/checks/bugprone-forward-declaration-namespace.rst @@ -1,7 +1,7 @@ -.. title:: clang-tidy - misc-forward-declaration-namespace +.. title:: clang-tidy - bugprone-forward-declaration-namespace -misc-forward-declaration-namespace -================================== +bugprone-forward-declaration-namespace +====================================== Checks if an unused forward declaration is in a wrong namespace. Index: docs/clang-tidy/checks/bugprone-inaccurate-erase.rst =================================================================== --- docs/clang-tidy/checks/bugprone-inaccurate-erase.rst +++ docs/clang-tidy/checks/bugprone-inaccurate-erase.rst @@ -1,7 +1,7 @@ -.. title:: clang-tidy - misc-inaccurate-erase +.. title:: clang-tidy - bugprone-inaccurate-erase -misc-inaccurate-erase -===================== +bugprone-inaccurate-erase +========================= Checks for inaccurate use of the ``erase()`` method. Index: docs/clang-tidy/checks/bugprone-move-forwarding-reference.rst =================================================================== --- docs/clang-tidy/checks/bugprone-move-forwarding-reference.rst +++ docs/clang-tidy/checks/bugprone-move-forwarding-reference.rst @@ -1,7 +1,7 @@ -.. title:: clang-tidy - misc-move-forwarding-reference +.. title:: clang-tidy - bugprone-move-forwarding-reference -misc-move-forwarding-reference -============================== +bugprone-move-forwarding-reference +================================== Warns if ``std::move`` is called on a forwarding reference, for example: Index: docs/clang-tidy/checks/bugprone-multiple-statement-macro.rst =================================================================== --- docs/clang-tidy/checks/bugprone-multiple-statement-macro.rst +++ docs/clang-tidy/checks/bugprone-multiple-statement-macro.rst @@ -1,7 +1,7 @@ -.. title:: clang-tidy - misc-multiple-statement-macro +.. title:: clang-tidy - bugprone-multiple-statement-macro -misc-multiple-statement-macro -============================= +bugprone-multiple-statement-macro +================================= Detect multiple statement macros that are used in unbraced conditionals. Only the first statement of the macro will be inside the conditional and the other Index: docs/clang-tidy/checks/bugprone-use-after-move.rst =================================================================== --- docs/clang-tidy/checks/bugprone-use-after-move.rst +++ docs/clang-tidy/checks/bugprone-use-after-move.rst @@ -1,7 +1,7 @@ -.. title:: clang-tidy - misc-use-after-move +.. title:: clang-tidy - bugprone-use-after-move -misc-use-after-move -=================== +bugprone-use-after-move +======================= Warns if an object is used after it has been moved, for example: Index: docs/clang-tidy/checks/bugprone-virtual-near-miss.rst =================================================================== --- docs/clang-tidy/checks/bugprone-virtual-near-miss.rst +++ docs/clang-tidy/checks/bugprone-virtual-near-miss.rst @@ -1,7 +1,7 @@ -.. title:: clang-tidy - misc-virtual-near-miss +.. title:: clang-tidy - bugprone-virtual-near-miss -misc-virtual-near-miss -====================== +bugprone-virtual-near-miss +========================== Warn if a function is a near miss (ie. the name is very similar and the function signiture is the same) to a virtual function from a base class. Index: docs/clang-tidy/checks/hicpp-invalid-access-moved.rst =================================================================== --- docs/clang-tidy/checks/hicpp-invalid-access-moved.rst +++ docs/clang-tidy/checks/hicpp-invalid-access-moved.rst @@ -1,10 +1,10 @@ .. title:: clang-tidy - hicpp-invalid-access-moved .. meta:: - :http-equiv=refresh: 5;URL=misc-use-after-move.html + :http-equiv=refresh: 5;URL=bugprone-use-after-move.html hicpp-invalid-access-moved ========================== -This check is an alias for `misc-use-after-move `_. +This check is an alias for `bugprone-use-after-move `_. Implements parts of the `rule 8.4.1 `_ to check if moved-from objects are accessed. Index: docs/clang-tidy/checks/list.rst =================================================================== --- docs/clang-tidy/checks/list.rst +++ docs/clang-tidy/checks/list.rst @@ -18,13 +18,22 @@ android-cloexec-socket boost-use-to-string bugprone-argument-comment + bugprone-assert-side-effect + bugprone-bool-pointer-implicit-conversion bugprone-copy-constructor-init bugprone-dangling-handle + bugprone-fold-init-type + bugprone-forward-declaration-namespace + bugprone-inaccurate-erase bugprone-integer-division bugprone-misplaced-operator-in-strlen-in-alloc + bugprone-move-forwarding-reference + bugprone-multiple-statement-macro bugprone-string-constructor bugprone-suspicious-memset-usage bugprone-undefined-memory-manipulation + bugprone-use-after-move + bugprone-virtual-near-miss cert-dcl03-c (redirects to misc-static-assert) cert-dcl21-cpp cert-dcl50-cpp @@ -82,7 +91,7 @@ hicpp-exception-baseclass hicpp-explicit-conversions (redirects to google-explicit-constructor) hicpp-function-size (redirects to readability-function-size) - hicpp-invalid-access-moved (redirects to misc-use-after-move) + hicpp-invalid-access-moved (redirects to bugprone-use-after-move) hicpp-member-init (redirects to cppcoreguidelines-pro-type-member-init) hicpp-move-const-arg (redirects to misc-move-const-arg) hicpp-named-parameter (redirects to readability-named-parameter) @@ -107,13 +116,8 @@ llvm-include-order llvm-namespace-comment llvm-twine-local - misc-assert-side-effect - misc-bool-pointer-implicit-conversion misc-definitions-in-headers - misc-fold-init-type - misc-forward-declaration-namespace misc-forwarding-reference-overload - misc-inaccurate-erase misc-incorrect-roundings misc-inefficient-algorithm misc-lambda-function-name @@ -123,8 +127,6 @@ misc-misplaced-widening-cast misc-move-const-arg misc-move-constructor-init - misc-move-forwarding-reference - misc-multiple-statement-macro misc-new-delete-overloads misc-noexcept-move-constructor misc-non-copyable-objects @@ -148,8 +150,6 @@ misc-unused-parameters misc-unused-raii misc-unused-using-decls - misc-use-after-move - misc-virtual-near-miss modernize-avoid-bind modernize-deprecated-headers modernize-loop-convert Index: test/clang-tidy/bugprone-assert-side-effect.cpp =================================================================== --- test/clang-tidy/bugprone-assert-side-effect.cpp +++ test/clang-tidy/bugprone-assert-side-effect.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s misc-assert-side-effect %t -- -config="{CheckOptions: [{key: misc-assert-side-effect.CheckFunctionCalls, value: 1}, {key: misc-assert-side-effect.AssertMacros, value: 'assert,assert2,my_assert,convoluted_assert,msvc_assert'}]}" -- -fexceptions +// RUN: %check_clang_tidy %s bugprone-assert-side-effect %t -- -config="{CheckOptions: [{key: bugprone-assert-side-effect.CheckFunctionCalls, value: 1}, {key: bugprone-assert-side-effect.AssertMacros, value: 'assert,assert2,my_assert,convoluted_assert,msvc_assert'}]}" -- -fexceptions //===--- assert definition block ------------------------------------------===// int abort() { return 0; } @@ -68,7 +68,7 @@ assert(X == 1); assert(X = 1); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() with side effect [misc-assert-side-effect] + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() with side effect [bugprone-assert-side-effect] my_assert(X = 1); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found my_assert() with side effect convoluted_assert(X = 1); Index: test/clang-tidy/bugprone-bool-pointer-implicit-conversion.cpp =================================================================== --- test/clang-tidy/bugprone-bool-pointer-implicit-conversion.cpp +++ test/clang-tidy/bugprone-bool-pointer-implicit-conversion.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s misc-bool-pointer-implicit-conversion %t +// RUN: %check_clang_tidy %s bugprone-bool-pointer-implicit-conversion %t bool *SomeFunction(); void SomeOtherFunction(bool*); Index: test/clang-tidy/bugprone-fold-init-type.cpp =================================================================== --- test/clang-tidy/bugprone-fold-init-type.cpp +++ test/clang-tidy/bugprone-fold-init-type.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s misc-fold-init-type %t +// RUN: %check_clang_tidy %s bugprone-fold-init-type %t namespace std { template Index: test/clang-tidy/bugprone-forward-declaration-namespace.cpp =================================================================== --- test/clang-tidy/bugprone-forward-declaration-namespace.cpp +++ test/clang-tidy/bugprone-forward-declaration-namespace.cpp @@ -1,11 +1,11 @@ -// RUN: %check_clang_tidy %s misc-forward-declaration-namespace %t +// RUN: %check_clang_tidy %s bugprone-forward-declaration-namespace %t namespace { // This is a declaration in a wrong namespace. class T_A; -// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration 'T_A' is never referenced, but a declaration with the same name found in another namespace 'na' [misc-forward-declaration-namespace] +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration 'T_A' is never referenced, but a declaration with the same name found in another namespace 'na' [bugprone-forward-declaration-namespace] // CHECK-MESSAGES: note: a declaration of 'T_A' is found here -// CHECK-MESSAGES: :[[@LINE-3]]:7: warning: no definition found for 'T_A', but a definition with the same name 'T_A' found in another namespace '(global)' [misc-forward-declaration-namespace] +// CHECK-MESSAGES: :[[@LINE-3]]:7: warning: no definition found for 'T_A', but a definition with the same name 'T_A' found in another namespace '(global)' [bugprone-forward-declaration-namespace] // CHECK-MESSAGES: note: a definition of 'T_A' is found here } Index: test/clang-tidy/bugprone-inaccurate-erase.cpp =================================================================== --- test/clang-tidy/bugprone-inaccurate-erase.cpp +++ test/clang-tidy/bugprone-inaccurate-erase.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s misc-inaccurate-erase %t +// RUN: %check_clang_tidy %s bugprone-inaccurate-erase %t namespace std { template struct vec_iterator { @@ -66,7 +66,7 @@ std::vector v; v.erase(remove(v.begin(), v.end(), 10)); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this call will remove at most one item even when multiple items should be removed [misc-inaccurate-erase] + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this call will remove at most one item even when multiple items should be removed [bugprone-inaccurate-erase] // CHECK-FIXES: {{^ }}v.erase(remove(v.begin(), v.end(), 10), v.end());{{$}} v.erase(remove(v.begin(), v.end(), 20), v.end()); Index: test/clang-tidy/bugprone-move-forwarding-reference.cpp =================================================================== --- test/clang-tidy/bugprone-move-forwarding-reference.cpp +++ test/clang-tidy/bugprone-move-forwarding-reference.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s misc-move-forwarding-reference %t -- -- -std=c++14 -fno-delayed-template-parsing +// RUN: %check_clang_tidy %s bugprone-move-forwarding-reference %t -- -- -std=c++14 -fno-delayed-template-parsing namespace std { template struct remove_reference; Index: test/clang-tidy/bugprone-multiple-statement-macro.cpp =================================================================== --- test/clang-tidy/bugprone-multiple-statement-macro.cpp +++ test/clang-tidy/bugprone-multiple-statement-macro.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s misc-multiple-statement-macro %t +// RUN: %check_clang_tidy %s bugprone-multiple-statement-macro %t void F(); @@ -35,7 +35,7 @@ void positives() { if (1) BAD_MACRO(1); - // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: multiple statement macro used without braces; some statements will be unconditionally executed [misc-multiple-statement-macro] + // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: multiple statement macro used without braces; some statements will be unconditionally executed [bugprone-multiple-statement-macro] if (1) { } else BAD_MACRO(1); Index: test/clang-tidy/bugprone-use-after-move.cpp =================================================================== --- test/clang-tidy/bugprone-use-after-move.cpp +++ test/clang-tidy/bugprone-use-after-move.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s misc-use-after-move %t -- -- -std=c++11 -fno-delayed-template-parsing +// RUN: %check_clang_tidy %s bugprone-use-after-move %t -- -- -std=c++11 -fno-delayed-template-parsing typedef decltype(nullptr) nullptr_t; Index: test/clang-tidy/bugprone-virtual-near-miss.cpp =================================================================== --- test/clang-tidy/bugprone-virtual-near-miss.cpp +++ test/clang-tidy/bugprone-virtual-near-miss.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s misc-virtual-near-miss %t +// RUN: %check_clang_tidy %s bugprone-virtual-near-miss %t class NoDefinedClass1; class NoDefinedClass2; @@ -15,7 +15,7 @@ // Should not warn "do you want to override 'gunk'?", because gunk is already // overriden by this class. virtual void funk(); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Derived::funk' has a similar name and the same signature as virtual method 'Base::func'; did you mean to override it? [misc-virtual-near-miss] + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Derived::funk' has a similar name and the same signature as virtual method 'Base::func'; did you mean to override it? [bugprone-virtual-near-miss] // CHECK-FIXES: virtual void func(); void func2(); Index: test/clang-tidy/cppcoreguidelines-owning-memory.cpp =================================================================== --- test/clang-tidy/cppcoreguidelines-owning-memory.cpp +++ test/clang-tidy/cppcoreguidelines-owning-memory.cpp @@ -54,7 +54,7 @@ } /// FIXME: CSA finds it, but the report is misleading. Ownersemantics can catch this -/// by flow analysis similar to misc-use-after-move. +/// by flow analysis similar to bugprone-use-after-move. void csa_not_finding_leak() { gsl::owner o1 = new int(42); // Ok