summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/misc
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/clang-tidy/misc')
-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/clang-tidy/misc/SizeofContainerCheck.cpp49
-rw-r--r--clang-tools-extra/clang-tidy/misc/SizeofContainerCheck.h36
4 files changed, 0 insertions, 88 deletions
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/clang-tidy/misc/SizeofContainerCheck.cpp b/clang-tools-extra/clang-tidy/misc/SizeofContainerCheck.cpp
deleted file mode 100644
index de4e8ad1b33..00000000000
--- a/clang-tools-extra/clang-tidy/misc/SizeofContainerCheck.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-//===--- SizeofContainerCheck.cpp - clang-tidy-----------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "SizeofContainerCheck.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/ASTMatchers/ASTMatchFinder.h"
-
-using namespace clang::ast_matchers;
-
-namespace clang {
-namespace tidy {
-namespace misc {
-
-void SizeofContainerCheck::registerMatchers(MatchFinder *Finder) {
- Finder->addMatcher(
- expr(unless(isInTemplateInstantiation()),
- expr(sizeOfExpr(has(ignoringParenImpCasts(
- expr(hasType(hasCanonicalType(hasDeclaration(cxxRecordDecl(
- matchesName("^(::std::|::string)"),
- unless(matchesName("^::std::(bitset|array)$")),
- hasMethod(cxxMethodDecl(hasName("size"), isPublic(),
- isConst())))))))))))
- .bind("sizeof"),
- // Ignore ARRAYSIZE(<array of containers>) pattern.
- unless(hasAncestor(binaryOperator(
- anyOf(hasOperatorName("/"), hasOperatorName("%")),
- hasLHS(ignoringParenCasts(sizeOfExpr(expr()))),
- hasRHS(ignoringParenCasts(equalsBoundNode("sizeof"))))))),
- this);
-}
-
-void SizeofContainerCheck::check(const MatchFinder::MatchResult &Result) {
- const auto *SizeOf =
- Result.Nodes.getNodeAs<UnaryExprOrTypeTraitExpr>("sizeof");
-
- auto Diag =
- diag(SizeOf->getLocStart(), "sizeof() doesn't return the size of the "
- "container; did you mean .size()?");
-}
-
-} // namespace misc
-} // namespace tidy
-} // namespace clang
diff --git a/clang-tools-extra/clang-tidy/misc/SizeofContainerCheck.h b/clang-tools-extra/clang-tidy/misc/SizeofContainerCheck.h
deleted file mode 100644
index ed13ca56d9c..00000000000
--- a/clang-tools-extra/clang-tidy/misc/SizeofContainerCheck.h
+++ /dev/null
@@ -1,36 +0,0 @@
-//===--- SizeofContainerCheck.h - clang-tidy---------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SIZEOF_CONTAINER_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SIZEOF_CONTAINER_H
-
-#include "../ClangTidy.h"
-
-namespace clang {
-namespace tidy {
-namespace misc {
-
-/// 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
-class SizeofContainerCheck : public ClangTidyCheck {
-public:
- SizeofContainerCheck(StringRef Name, ClangTidyContext *Context)
- : ClangTidyCheck(Name, Context) {}
- void registerMatchers(ast_matchers::MatchFinder *Finder) override;
- void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
-};
-
-} // namespace misc
-} // namespace tidy
-} // namespace clang
-
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SIZEOF_CONTAINER_H
OpenPOWER on IntegriCloud