summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.h
diff options
context:
space:
mode:
authorGabor Horvath <xazax.hun@gmail.com>2015-02-07 19:54:19 +0000
committerGabor Horvath <xazax.hun@gmail.com>2015-02-07 19:54:19 +0000
commit3880bee0ff044e2ddd7790c45a919436123830f8 (patch)
tree35328cd32f6a15ac7c3668fe120139311be48e34 /clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.h
parent17d9015d270a13d799a498a40a5ce3d8b660ee0a (diff)
downloadbcm5719-llvm-3880bee0ff044e2ddd7790c45a919436123830f8.tar.gz
bcm5719-llvm-3880bee0ff044e2ddd7790c45a919436123830f8.zip
[clang-tidy] Checker for inefficient use of algorithms on associative containers
Summary: Associative containers implements some of the algorithms as methods which should be preferred to the algorithms in the algorithm header. The methods can take advantage of the order of the elements. Reviewers: alexfh Reviewed By: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D7246 llvm-svn: 228505
Diffstat (limited to 'clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.h')
-rw-r--r--clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.h b/clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.h
new file mode 100644
index 00000000000..f55297f0378
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/misc/InefficientAlgorithmCheck.h
@@ -0,0 +1,34 @@
+//===--- InefficientAlgorithmCheck.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_INEFFICIENT_ALGORITHM_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_INEFFICIENT_ALGORITHM_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+
+/// \brief Warns on inefficient use of STL algorithms on associative containers.
+///
+/// Associative containers implements some of the algorithms as methods which
+/// should be preferred to the algorithms in the algorithm header. The methods
+/// can take advanatage of the order of the elements.
+class InefficientAlgorithmCheck : public ClangTidyCheck {
+public:
+ InefficientAlgorithmCheck(StringRef Name, ClangTidyContext *Context)
+ : ClangTidyCheck(Name, Context) {}
+ void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+ void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_INEFFICIENT_ALGORITHM_H
OpenPOWER on IntegriCloud