summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
diff options
context:
space:
mode:
authorSamuel Benzaquen <sbenza@google.com>2016-02-17 16:13:14 +0000
committerSamuel Benzaquen <sbenza@google.com>2016-02-17 16:13:14 +0000
commit1fb8bc7a30cca842908bdcef576aaa5e93a99842 (patch)
tree62c152f98cb94c1aac877f7e39701c210c6b8e98 /clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
parent07d72f4f4903d51deeb81ca3bf0441600656a745 (diff)
downloadbcm5719-llvm-1fb8bc7a30cca842908bdcef576aaa5e93a99842.tar.gz
bcm5719-llvm-1fb8bc7a30cca842908bdcef576aaa5e93a99842.zip
[clang-tidy] Match the type against the get() method we are calling,
instead of a get() method we find in the class. The duck typed smart pointer class could have overloaded get() methods and we should only skip the one that matches. llvm-svn: 261102
Diffstat (limited to 'clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp b/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
index 158fe2e37e8..e3686359fa0 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
@@ -25,7 +25,9 @@ internal::Matcher<Expr> callToGet(internal::Matcher<Decl> OnClass) {
pointsTo(decl(OnClass).bind("ptr_to_ptr"))))))
.bind("smart_pointer")),
unless(callee(memberExpr(hasObjectExpression(cxxThisExpr())))),
- callee(cxxMethodDecl(hasName("get"))))
+ callee(cxxMethodDecl(
+ hasName("get"),
+ returns(qualType(pointsTo(type().bind("getType")))))))
.bind("redundant_get");
}
@@ -35,10 +37,8 @@ void registerMatchersForGetArrowStart(MatchFinder *Finder,
recordDecl().bind("duck_typing"),
has(cxxMethodDecl(hasName("operator->"),
returns(qualType(pointsTo(type().bind("op->Type")))))),
- has(cxxMethodDecl(hasName("operator*"),
- returns(qualType(references(type().bind("op*Type")))))),
- has(cxxMethodDecl(hasName("get"),
- returns(qualType(pointsTo(type().bind("getType")))))));
+ has(cxxMethodDecl(hasName("operator*"), returns(qualType(references(
+ type().bind("op*Type")))))));
// Catch 'ptr.get()->Foo()'
Finder->addMatcher(memberExpr(expr().bind("memberExpr"), isArrow(),
OpenPOWER on IntegriCloud