diff options
Diffstat (limited to 'clang-tools-extra')
| -rw-r--r-- | clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp | 3 | ||||
| -rw-r--r-- | clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp (renamed from clang-tools-extra/clang-tidy/misc/StringConstructorCheck.cpp) | 4 | ||||
| -rw-r--r-- | clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.h (renamed from clang-tools-extra/clang-tidy/misc/StringConstructorCheck.h) | 12 | ||||
| -rw-r--r-- | clang-tools-extra/clang-tidy/misc/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp | 3 | ||||
| -rw-r--r-- | clang-tools-extra/docs/ReleaseNotes.rst | 3 | ||||
| -rw-r--r-- | clang-tools-extra/docs/clang-tidy/checks/bugprone-string-constructor.rst (renamed from clang-tools-extra/docs/clang-tidy/checks/misc-string-constructor.rst) | 6 | ||||
| -rw-r--r-- | clang-tools-extra/docs/clang-tidy/checks/list.rst | 2 | ||||
| -rw-r--r-- | clang-tools-extra/test/clang-tidy/bugprone-string-constructor.cpp (renamed from clang-tools-extra/test/clang-tidy/misc-string-constructor.cpp) | 4 |
10 files changed, 21 insertions, 18 deletions
diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp index a5b3d640b20..1719500fb86 100644 --- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp @@ -13,6 +13,7 @@ #include "CopyConstructorInitCheck.h" #include "IntegerDivisionCheck.h" #include "MisplacedOperatorInStrlenInAllocCheck.h" +#include "StringConstructorCheck.h" #include "SuspiciousMemsetUsageCheck.h" #include "UndefinedMemoryManipulationCheck.h" @@ -29,6 +30,8 @@ public: "bugprone-integer-division"); CheckFactories.registerCheck<MisplacedOperatorInStrlenInAllocCheck>( "bugprone-misplaced-operator-in-strlen-in-alloc"); + CheckFactories.registerCheck<StringConstructorCheck>( + "bugprone-string-constructor"); CheckFactories.registerCheck<SuspiciousMemsetUsageCheck>( "bugprone-suspicious-memset-usage"); CheckFactories.registerCheck<UndefinedMemoryManipulationCheck>( diff --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt index 46101c6037e..db724ea1f0a 100644 --- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt @@ -5,6 +5,7 @@ add_clang_library(clangTidyBugproneModule CopyConstructorInitCheck.cpp IntegerDivisionCheck.cpp MisplacedOperatorInStrlenInAllocCheck.cpp + StringConstructorCheck.cpp SuspiciousMemsetUsageCheck.cpp UndefinedMemoryManipulationCheck.cpp diff --git a/clang-tools-extra/clang-tidy/misc/StringConstructorCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp index 7ff488133f3..5607ce6a487 100644 --- a/clang-tools-extra/clang-tidy/misc/StringConstructorCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp @@ -16,7 +16,7 @@ using namespace clang::ast_matchers; namespace clang { namespace tidy { -namespace misc { +namespace bugprone { AST_MATCHER_P(IntegerLiteral, isBiggerThan, unsigned, N) { return Node.getValue().getZExtValue() > N; @@ -129,6 +129,6 @@ void StringConstructorCheck::check(const MatchFinder::MatchResult &Result) { } } -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang diff --git a/clang-tools-extra/clang-tidy/misc/StringConstructorCheck.h b/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.h index ca32fb6f962..52e9791fd9a 100644 --- a/clang-tools-extra/clang-tidy/misc/StringConstructorCheck.h +++ b/clang-tools-extra/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 @@ private: 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 diff --git a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt index 9e74387d4ab..b67b4f7ddc3 100644 --- a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt @@ -31,7 +31,6 @@ add_clang_library(clangTidyMiscModule SizeofExpressionCheck.cpp StaticAssertCheck.cpp StringCompareCheck.cpp - StringConstructorCheck.cpp StringIntegerAssignmentCheck.cpp StringLiteralWithEmbeddedNulCheck.cpp SuspiciousEnumUsageCheck.cpp diff --git a/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp b/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp index 5448c04d3ad..8dab93e9edd 100644 --- a/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp +++ b/clang-tools-extra/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 @@ public: "misc-sizeof-expression"); CheckFactories.registerCheck<StaticAssertCheck>("misc-static-assert"); CheckFactories.registerCheck<StringCompareCheck>("misc-string-compare"); - CheckFactories.registerCheck<StringConstructorCheck>( - "misc-string-constructor"); CheckFactories.registerCheck<StringIntegerAssignmentCheck>( "misc-string-integer-assignment"); CheckFactories.registerCheck<StringLiteralWithEmbeddedNulCheck>( diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index c357b86a43f..6032414c11c 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -57,6 +57,9 @@ The improvements are... Improvements to clang-tidy -------------------------- +- The 'misc-string-constructor' check was renamed to `bugprone-string-constructor + <http://clang.llvm.org/extra/clang-tidy/checks/bugprone-string-constructor.html>`_ + - New `google-avoid-throwing-objc-exception <http://clang.llvm.org/extra/clang-tidy/checks/google-objc-avoid-throwing-exception.html>`_ check diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc-string-constructor.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone-string-constructor.rst index a4f39202823..5deedf1f665 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/misc-string-constructor.rst +++ b/clang-tools-extra/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. diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst index 8b5957af6c2..5d714741bd0 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/list.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst @@ -20,6 +20,7 @@ Clang-Tidy Checks bugprone-copy-constructor-init bugprone-integer-division bugprone-misplaced-operator-in-strlen-in-alloc + bugprone-string-constructor bugprone-suspicious-memset-usage bugprone-undefined-memory-manipulation cert-dcl03-c (redirects to misc-static-assert) <cert-dcl03-c> @@ -132,7 +133,6 @@ Clang-Tidy Checks 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 diff --git a/clang-tools-extra/test/clang-tidy/misc-string-constructor.cpp b/clang-tools-extra/test/clang-tidy/bugprone-string-constructor.cpp index 85ae7450f02..51d91305882 100644 --- a/clang-tools-extra/test/clang-tidy/misc-string-constructor.cpp +++ b/clang-tools-extra/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 <typename T> @@ -21,7 +21,7 @@ extern const char kText3[]; 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 |

