Do not touch get() calls on 'this' object.

Summary:
These calls are part of the implementation of the smart pointer itself
and chaning it is likely to be wrong.
Example:
  T& operator*() const { return *get(); }

Reviewers: djasper

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D3540

llvm-svn: 207525
This commit is contained in:
Samuel Benzaquen 2014-04-29 13:41:23 +00:00
parent b3268e71e2
commit 20e93f39c1
2 changed files with 11 additions and 0 deletions

View File

@ -22,6 +22,7 @@ internal::Matcher<Expr> callToGet(internal::Matcher<Decl> OnClass) {
on(expr(anyOf(hasType(OnClass),
hasType(qualType(pointsTo(decl(OnClass).bind(
"ptr_to_ptr")))))).bind("smart_pointer")),
unless(callee(memberExpr(hasObjectExpression(thisExpr())))),
callee(methodDecl(hasName("get")))).bind("redundant_get");
}

View File

@ -81,6 +81,16 @@ void Positive() {
// CHECK-NOT: warning
void Negative() {
struct NegPtr {
int* get();
int* operator->() {
return &*this->get();
}
int& operator*() {
return *get();
}
};
std::unique_ptr<Bar>* u;
u->get()->Do();