aboutsummaryrefslogtreecommitdiff
path: root/clang-tidy/readability
diff options
context:
space:
mode:
authorManuel Klimek <klimek@google.com>2017-08-02 13:13:11 +0000
committerManuel Klimek <klimek@google.com>2017-08-02 13:13:11 +0000
commitf6d9f47621a7ca87268eea73a9b249bc67592a3c (patch)
tree997124ffab598717eca0cad0979606619cb64550 /clang-tidy/readability
parenta2f77bf8920bc71694c0ebee24d23d0684bd94ee (diff)
Adapt clang-tidy checks to changing semantics of hasDeclaration.
Differential Revision: https://reviews.llvm.org/D36154 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@309810 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clang-tidy/readability')
-rw-r--r--clang-tidy/readability/ContainerSizeEmptyCheck.cpp22
-rw-r--r--clang-tidy/readability/RedundantStringCStrCheck.cpp3
-rw-r--r--clang-tidy/readability/RedundantStringInitCheck.cpp3
3 files changed, 16 insertions, 12 deletions
diff --git a/clang-tidy/readability/ContainerSizeEmptyCheck.cpp b/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
index 24680eb6..5604354f 100644
--- a/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
+++ b/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
@@ -32,16 +32,18 @@ void ContainerSizeEmptyCheck::registerMatchers(MatchFinder *Finder) {
if (!getLangOpts().CPlusPlus)
return;
- const auto ValidContainer = cxxRecordDecl(isSameOrDerivedFrom(
- namedDecl(
- has(cxxMethodDecl(
- isConst(), parameterCountIs(0), isPublic(), hasName("size"),
- returns(qualType(isInteger(), unless(booleanType()))))
- .bind("size")),
- has(cxxMethodDecl(isConst(), parameterCountIs(0), isPublic(),
- hasName("empty"), returns(booleanType()))
- .bind("empty")))
- .bind("container")));
+ const auto ValidContainer = qualType(hasUnqualifiedDesugaredType(
+ recordType(hasDeclaration(cxxRecordDecl(isSameOrDerivedFrom(
+ namedDecl(
+ has(cxxMethodDecl(
+ isConst(), parameterCountIs(0), isPublic(),
+ hasName("size"),
+ returns(qualType(isInteger(), unless(booleanType()))))
+ .bind("size")),
+ has(cxxMethodDecl(isConst(), parameterCountIs(0), isPublic(),
+ hasName("empty"), returns(booleanType()))
+ .bind("empty")))
+ .bind("container")))))));
const auto WrongUse = anyOf(
hasParent(binaryOperator(
diff --git a/clang-tidy/readability/RedundantStringCStrCheck.cpp b/clang-tidy/readability/RedundantStringCStrCheck.cpp
index c6b384b3..21f4a8a5 100644
--- a/clang-tidy/readability/RedundantStringCStrCheck.cpp
+++ b/clang-tidy/readability/RedundantStringCStrCheck.cpp
@@ -77,7 +77,8 @@ void RedundantStringCStrCheck::registerMatchers(
return;
// Match expressions of type 'string' or 'string*'.
- const auto StringDecl = cxxRecordDecl(hasName("::std::basic_string"));
+ const auto StringDecl = type(hasUnqualifiedDesugaredType(recordType(
+ hasDeclaration(cxxRecordDecl(hasName("::std::basic_string"))))));
const auto StringExpr =
expr(anyOf(hasType(StringDecl), hasType(qualType(pointsTo(StringDecl)))));
diff --git a/clang-tidy/readability/RedundantStringInitCheck.cpp b/clang-tidy/readability/RedundantStringInitCheck.cpp
index b881e226..46ce2a47 100644
--- a/clang-tidy/readability/RedundantStringInitCheck.cpp
+++ b/clang-tidy/readability/RedundantStringInitCheck.cpp
@@ -47,7 +47,8 @@ void RedundantStringInitCheck::registerMatchers(MatchFinder *Finder) {
// string bar("");
Finder->addMatcher(
namedDecl(
- varDecl(hasType(cxxRecordDecl(hasName("basic_string"))),
+ varDecl(hasType(hasUnqualifiedDesugaredType(recordType(
+ hasDeclaration(cxxRecordDecl(hasName("basic_string")))))),
hasInitializer(expr(ignoringImplicit(anyOf(
EmptyStringCtorExpr,
EmptyStringCtorExprWithTemporaries)))