summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp3
-rw-r--r--clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt1
-rw-r--r--clang-tools-extra/clang-tidy/bugprone/SizeofContainerCheck.cpp (renamed from clang-tools-extra/clang-tidy/misc/SizeofContainerCheck.cpp)4
-rw-r--r--clang-tools-extra/clang-tidy/bugprone/SizeofContainerCheck.h (renamed from clang-tools-extra/clang-tidy/misc/SizeofContainerCheck.h)12
-rw-r--r--clang-tools-extra/clang-tidy/misc/CMakeLists.txt1
-rw-r--r--clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp2
-rw-r--r--clang-tools-extra/docs/ReleaseNotes.rst3
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/bugprone-sizeof-container.rst (renamed from clang-tools-extra/docs/clang-tidy/checks/misc-sizeof-container.rst)6
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/list.rst2
-rw-r--r--clang-tools-extra/test/clang-tidy/bugprone-sizeof-container.cpp (renamed from clang-tools-extra/test/clang-tidy/misc-sizeof-container.cpp)4
10 files changed, 21 insertions, 17 deletions
diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 922a79d064a..ac218d7cd09 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -28,6 +28,7 @@
#include "MisplacedWideningCastCheck.h"
#include "MoveForwardingReferenceCheck.h"
#include "MultipleStatementMacroCheck.h"
+#include "SizeofContainerCheck.h"
#include "SizeofExpressionCheck.h"
#include "StringConstructorCheck.h"
#include "StringIntegerAssignmentCheck.h"
@@ -87,6 +88,8 @@ public:
"bugprone-move-forwarding-reference");
CheckFactories.registerCheck<MultipleStatementMacroCheck>(
"bugprone-multiple-statement-macro");
+ CheckFactories.registerCheck<SizeofContainerCheck>(
+ "bugprone-sizeof-container");
CheckFactories.registerCheck<SizeofExpressionCheck>(
"bugprone-sizeof-expression");
CheckFactories.registerCheck<StringConstructorCheck>(
diff --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index 4bd83a92994..1c8b9b46679 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -20,6 +20,7 @@ add_clang_library(clangTidyBugproneModule
MisplacedWideningCastCheck.cpp
MoveForwardingReferenceCheck.cpp
MultipleStatementMacroCheck.cpp
+ SizeofContainerCheck.cpp
SizeofExpressionCheck.cpp
StringConstructorCheck.cpp
StringIntegerAssignmentCheck.cpp
diff --git a/clang-tools-extra/clang-tidy/misc/SizeofContainerCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SizeofContainerCheck.cpp
index de4e8ad1b33..b4a019e996e 100644
--- a/clang-tools-extra/clang-tidy/misc/SizeofContainerCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SizeofContainerCheck.cpp
@@ -15,7 +15,7 @@ using namespace clang::ast_matchers;
namespace clang {
namespace tidy {
-namespace misc {
+namespace bugprone {
void SizeofContainerCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(
@@ -44,6 +44,6 @@ void SizeofContainerCheck::check(const MatchFinder::MatchResult &Result) {
"container; did you mean .size()?");
}
-} // namespace misc
+} // namespace bugprone
} // namespace tidy
} // namespace clang
diff --git a/clang-tools-extra/clang-tidy/misc/SizeofContainerCheck.h b/clang-tools-extra/clang-tidy/bugprone/SizeofContainerCheck.h
index ed13ca56d9c..76b82b00779 100644
--- a/clang-tools-extra/clang-tidy/misc/SizeofContainerCheck.h
+++ b/clang-tools-extra/clang-tidy/bugprone/SizeofContainerCheck.h
@@ -7,20 +7,20 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SIZEOF_CONTAINER_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SIZEOF_CONTAINER_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SIZEOFCONTAINERCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SIZEOFCONTAINERCHECK_H
#include "../ClangTidy.h"
namespace clang {
namespace tidy {
-namespace misc {
+namespace bugprone {
/// Find usages of sizeof on expressions of STL container types. Most likely the
/// user wanted to use `.size()` instead.
///
/// For the user-facing documentation see:
-/// http://clang.llvm.org/extra/clang-tidy/checks/misc-sizeof-container.html
+/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-sizeof-container.html
class SizeofContainerCheck : public ClangTidyCheck {
public:
SizeofContainerCheck(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_SIZEOF_CONTAINER_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SIZEOFCONTAINERCHECK_H
diff --git a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt
index 4d8cedd81da..e81a528ff30 100644
--- a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt
@@ -8,7 +8,6 @@ add_clang_library(clangTidyMiscModule
NewDeleteOverloadsCheck.cpp
NonCopyableObjects.cpp
RedundantExpressionCheck.cpp
- SizeofContainerCheck.cpp
StaticAssertCheck.cpp
ThrowByValueCatchByReferenceCheck.cpp
UniqueptrResetReleaseCheck.cpp
diff --git a/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp b/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
index 9a9ebb6f9d2..b49f7947bc1 100644
--- a/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
@@ -15,7 +15,6 @@
#include "NewDeleteOverloadsCheck.h"
#include "NonCopyableObjects.h"
#include "RedundantExpressionCheck.h"
-#include "SizeofContainerCheck.h"
#include "StaticAssertCheck.h"
#include "ThrowByValueCatchByReferenceCheck.h"
#include "UnconventionalAssignOperatorCheck.h"
@@ -43,7 +42,6 @@ public:
"misc-non-copyable-objects");
CheckFactories.registerCheck<RedundantExpressionCheck>(
"misc-redundant-expression");
- CheckFactories.registerCheck<SizeofContainerCheck>("misc-sizeof-container");
CheckFactories.registerCheck<StaticAssertCheck>("misc-static-assert");
CheckFactories.registerCheck<ThrowByValueCatchByReferenceCheck>(
"misc-throw-by-value-catch-by-reference");
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst
index fa1a6e01be4..ffb3c45a0d4 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -137,6 +137,9 @@ Improvements to clang-tidy
- The 'misc-misplaced-widening-cast' check was renamed to `bugprone-misplaced-widening-cast
<http://clang.llvm.org/extra/clang-tidy/checks/bugprone-misplaced-widening-cast.html>`_
+- The 'misc-sizeof-container' check was renamed to `bugprone-sizeof-container
+ <http://clang.llvm.org/extra/clang-tidy/checks/bugprone-sizeof-container.html>`_
+
- The 'misc-sizeof-expression' check was renamed to `bugprone-sizeof-expression
<http://clang.llvm.org/extra/clang-tidy/checks/bugprone-sizeof-expression.html>`_
diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc-sizeof-container.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone-sizeof-container.rst
index 9ee4440667e..fb2f0b2a680 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/misc-sizeof-container.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone-sizeof-container.rst
@@ -1,7 +1,7 @@
-.. title:: clang-tidy - misc-sizeof-container
+.. title:: clang-tidy - bugprone-sizeof-container
-misc-sizeof-container
-=====================
+bugprone-sizeof-container
+=========================
The check finds usages of ``sizeof`` on expressions of STL container types. Most
likely the user wanted to use ``.size()`` instead.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index b30a41d71d9..9194d627fdc 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -36,6 +36,7 @@ Clang-Tidy Checks
bugprone-misplaced-widening-cast
bugprone-move-forwarding-reference
bugprone-multiple-statement-macro
+ bugprone-sizeof-container
bugprone-sizeof-expression
bugprone-string-constructor
bugprone-string-integer-assignment
@@ -146,7 +147,6 @@ Clang-Tidy Checks
misc-new-delete-overloads
misc-non-copyable-objects
misc-redundant-expression
- misc-sizeof-container
misc-static-assert
misc-throw-by-value-catch-by-reference
misc-unconventional-assign-operator
diff --git a/clang-tools-extra/test/clang-tidy/misc-sizeof-container.cpp b/clang-tools-extra/test/clang-tidy/bugprone-sizeof-container.cpp
index 472587e18dd..27798d6c398 100644
--- a/clang-tools-extra/test/clang-tidy/misc-sizeof-container.cpp
+++ b/clang-tools-extra/test/clang-tidy/bugprone-sizeof-container.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s misc-sizeof-container %t -- -- -std=c++11 -target x86_64-unknown-unknown
+// RUN: %check_clang_tidy %s bugprone-sizeof-container %t -- -- -std=c++11 -target x86_64-unknown-unknown
namespace std {
@@ -64,7 +64,7 @@ void f() {
std::vector<int> v;
int a = 42 + sizeof(s1);
-// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: sizeof() doesn't return the size of the container; did you mean .size()? [misc-sizeof-container]
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: sizeof() doesn't return the size of the container; did you mean .size()? [bugprone-sizeof-container]
a = 123 * sizeof(s2);
// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: sizeof() doesn't return the size
a = 45 + sizeof(s2 + "asdf");
OpenPOWER on IntegriCloud