Index: clang-tidy/bugprone/BugproneTidyModule.cpp =================================================================== --- clang-tidy/bugprone/BugproneTidyModule.cpp +++ clang-tidy/bugprone/BugproneTidyModule.cpp @@ -12,6 +12,7 @@ #include "../ClangTidyModuleRegistry.h" #include "CopyConstructorInitCheck.h" #include "IntegerDivisionCheck.h" +#include "StringConstructorCheck.h" #include "SuspiciousMemsetUsageCheck.h" #include "UndefinedMemoryManipulationCheck.h" @@ -26,6 +27,8 @@ "bugprone-copy-constructor-init"); CheckFactories.registerCheck( "bugprone-integer-division"); + CheckFactories.registerCheck( + "bugprone-string-constructor"); CheckFactories.registerCheck( "bugprone-suspicious-memset-usage"); CheckFactories.registerCheck( Index: clang-tidy/bugprone/CMakeLists.txt =================================================================== --- clang-tidy/bugprone/CMakeLists.txt +++ clang-tidy/bugprone/CMakeLists.txt @@ -4,6 +4,7 @@ BugproneTidyModule.cpp CopyConstructorInitCheck.cpp IntegerDivisionCheck.cpp + StringConstructorCheck.cpp SuspiciousMemsetUsageCheck.cpp UndefinedMemoryManipulationCheck.cpp Index: clang-tidy/bugprone/StringConstructorCheck.h =================================================================== --- clang-tidy/bugprone/StringConstructorCheck.h +++ clang-tidy/bugprone/StringConstructorCheck.h @@ -7,19 +7,19 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_STRING_CONSTRUCTOR_H -#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_STRING_CONSTRUCTOR_H +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_STRING_CONSTRUCTOR_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_STRING_CONSTRUCTOR_H #include "../ClangTidy.h" namespace clang { namespace tidy { -namespace misc { +namespace bugprone { /// Finds suspicious string constructor and check their parameters. /// /// For the user-facing documentation see: -/// http://clang.llvm.org/extra/clang-tidy/checks/misc-string-constructor.html +/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-string-constructor.html class StringConstructorCheck : public ClangTidyCheck { public: StringConstructorCheck(StringRef Name, ClangTidyContext *Context); @@ -32,8 +32,8 @@ const unsigned int LargeLengthThreshold; }; -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang -#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_STRING_CONSTRUCTOR_H +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_STRING_CONSTRUCTOR_H Index: clang-tidy/bugprone/StringConstructorCheck.cpp =================================================================== --- clang-tidy/bugprone/StringConstructorCheck.cpp +++ clang-tidy/bugprone/StringConstructorCheck.cpp @@ -16,7 +16,7 @@ namespace clang { namespace tidy { -namespace misc { +namespace bugprone { AST_MATCHER_P(IntegerLiteral, isBiggerThan, unsigned, N) { return Node.getValue().getZExtValue() > N; @@ -129,6 +129,6 @@ } } -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang Index: clang-tidy/misc/CMakeLists.txt =================================================================== --- clang-tidy/misc/CMakeLists.txt +++ clang-tidy/misc/CMakeLists.txt @@ -31,7 +31,6 @@ SizeofExpressionCheck.cpp StaticAssertCheck.cpp StringCompareCheck.cpp - StringConstructorCheck.cpp StringIntegerAssignmentCheck.cpp StringLiteralWithEmbeddedNulCheck.cpp SuspiciousEnumUsageCheck.cpp Index: clang-tidy/misc/MiscTidyModule.cpp =================================================================== --- clang-tidy/misc/MiscTidyModule.cpp +++ clang-tidy/misc/MiscTidyModule.cpp @@ -38,7 +38,6 @@ #include "SizeofExpressionCheck.h" #include "StaticAssertCheck.h" #include "StringCompareCheck.h" -#include "StringConstructorCheck.h" #include "StringIntegerAssignmentCheck.h" #include "StringLiteralWithEmbeddedNulCheck.h" #include "SuspiciousEnumUsageCheck.h" @@ -114,8 +113,6 @@ "misc-sizeof-expression"); CheckFactories.registerCheck("misc-static-assert"); CheckFactories.registerCheck("misc-string-compare"); - CheckFactories.registerCheck( - "misc-string-constructor"); CheckFactories.registerCheck( "misc-string-integer-assignment"); CheckFactories.registerCheck( Index: docs/ReleaseNotes.rst =================================================================== --- docs/ReleaseNotes.rst +++ docs/ReleaseNotes.rst @@ -57,6 +57,9 @@ Improvements to clang-tidy -------------------------- +- The 'misc-string-constructor' check was renamed to `bugprone-string-constructor + `_ + - New `google-avoid-throwing-objc-exception `_ check Index: docs/clang-tidy/checks/bugprone-string-constructor.rst =================================================================== --- docs/clang-tidy/checks/bugprone-string-constructor.rst +++ docs/clang-tidy/checks/bugprone-string-constructor.rst @@ -1,7 +1,7 @@ -.. title:: clang-tidy - misc-string-constructor +.. title:: clang-tidy - bugprone-string-constructor -misc-string-constructor -======================= +bugprone-string-constructor +=========================== Finds string constructors that are suspicious and probably errors. Index: docs/clang-tidy/checks/list.rst =================================================================== --- docs/clang-tidy/checks/list.rst +++ docs/clang-tidy/checks/list.rst @@ -19,6 +19,7 @@ boost-use-to-string bugprone-copy-constructor-init bugprone-integer-division + bugprone-string-constructor bugprone-suspicious-memset-usage bugprone-undefined-memory-manipulation cert-dcl03-c (redirects to misc-static-assert) @@ -131,7 +132,6 @@ misc-sizeof-expression misc-static-assert misc-string-compare - misc-string-constructor misc-string-integer-assignment misc-string-literal-with-embedded-nul misc-suspicious-enum-usage Index: test/clang-tidy/bugprone-string-constructor.cpp =================================================================== --- test/clang-tidy/bugprone-string-constructor.cpp +++ test/clang-tidy/bugprone-string-constructor.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s misc-string-constructor %t +// RUN: %check_clang_tidy %s bugprone-string-constructor %t namespace std { template @@ -21,7 +21,7 @@ void Test() { std::string str('x', 4); - // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor parameters are probably swapped; expecting string(count, character) [misc-string-constructor] + // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor parameters are probably swapped; expecting string(count, character) [bugprone-string-constructor] // CHECK-FIXES: std::string str(4, 'x'); std::wstring wstr(L'x', 4); // CHECK-MESSAGES: [[@LINE-1]]:16: warning: string constructor parameters are probably swapped