[clang-tidy] rename_check.py misc-sizeof-container bugprone-sizeof-container

llvm-svn: 327608
This commit is contained in:
Alexander Kornienko 2018-03-15 08:26:47 +00:00
parent 3273888536
commit 68fb65f413
10 changed files with 21 additions and 17 deletions

View File

@ -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>(

View File

@ -20,6 +20,7 @@ add_clang_library(clangTidyBugproneModule
MisplacedWideningCastCheck.cpp
MoveForwardingReferenceCheck.cpp
MultipleStatementMacroCheck.cpp
SizeofContainerCheck.cpp
SizeofExpressionCheck.cpp
StringConstructorCheck.cpp
StringIntegerAssignmentCheck.cpp

View File

@ -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

View File

@ -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

View File

@ -8,7 +8,6 @@ add_clang_library(clangTidyMiscModule
NewDeleteOverloadsCheck.cpp
NonCopyableObjects.cpp
RedundantExpressionCheck.cpp
SizeofContainerCheck.cpp
StaticAssertCheck.cpp
ThrowByValueCatchByReferenceCheck.cpp
UniqueptrResetReleaseCheck.cpp

View File

@ -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");

View File

@ -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>`_

View File

@ -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.

View File

@ -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

View File

@ -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");