aboutsummaryrefslogtreecommitdiff
path: root/clang-tidy/performance
diff options
context:
space:
mode:
authorHaojian Wu <hokein@google.com>2017-04-24 16:41:00 +0000
committerHaojian Wu <hokein@google.com>2017-04-24 16:41:00 +0000
commite1eb3e370d2ab7618b3bdbc0623caadad8f799cb (patch)
treeca6220ec8f00b2bde704094606a2fe08d489678a /clang-tidy/performance
parentc442dc17de9a8cd848cbf761c8f212f402a98b18 (diff)
[clang-tidy] Some Cleanups for performance-faster-string-find check.
NFC git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@301188 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clang-tidy/performance')
-rw-r--r--clang-tidy/performance/FasterStringFindCheck.cpp34
1 files changed, 12 insertions, 22 deletions
diff --git a/clang-tidy/performance/FasterStringFindCheck.cpp b/clang-tidy/performance/FasterStringFindCheck.cpp
index a8a9f662..29dac1bc 100644
--- a/clang-tidy/performance/FasterStringFindCheck.cpp
+++ b/clang-tidy/performance/FasterStringFindCheck.cpp
@@ -65,29 +65,19 @@ void FasterStringFindCheck::registerMatchers(MatchFinder *Finder) {
const auto SingleChar =
expr(ignoringParenCasts(stringLiteral(hasSize(1)).bind("literal")));
-
const auto StringFindFunctions =
- anyOf(hasName("find"), hasName("rfind"), hasName("find_first_of"),
- hasName("find_first_not_of"), hasName("find_last_of"),
- hasName("find_last_not_of"));
-
- llvm::Optional<ast_matchers::internal::Matcher<NamedDecl>> IsStringClass;
-
- for (const auto &ClassName : StringLikeClasses) {
- const auto HasName = hasName(ClassName);
- IsStringClass = IsStringClass ? anyOf(*IsStringClass, HasName) : HasName;
- }
-
- if (IsStringClass) {
- Finder->addMatcher(
- cxxMemberCallExpr(
- callee(functionDecl(StringFindFunctions).bind("func")),
- anyOf(argumentCountIs(1), argumentCountIs(2)),
- hasArgument(0, SingleChar),
- on(expr(hasType(recordDecl(*IsStringClass)),
- unless(hasSubstitutedType())))),
- this);
- }
+ hasAnyName("find", "rfind", "find_first_of", "find_first_not_of",
+ "find_last_of", "find_last_not_of");
+
+ Finder->addMatcher(
+ cxxMemberCallExpr(
+ callee(functionDecl(StringFindFunctions).bind("func")),
+ anyOf(argumentCountIs(1), argumentCountIs(2)),
+ hasArgument(0, SingleChar),
+ on(expr(hasType(recordDecl(hasAnyName(SmallVector<StringRef, 4>(
+ StringLikeClasses.begin(), StringLikeClasses.end())))),
+ unless(hasSubstitutedType())))),
+ this);
}
void FasterStringFindCheck::check(const MatchFinder::MatchResult &Result) {