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:
parent
b3268e71e2
commit
20e93f39c1
|
@ -22,6 +22,7 @@ internal::Matcher<Expr> callToGet(internal::Matcher<Decl> OnClass) {
|
||||||
on(expr(anyOf(hasType(OnClass),
|
on(expr(anyOf(hasType(OnClass),
|
||||||
hasType(qualType(pointsTo(decl(OnClass).bind(
|
hasType(qualType(pointsTo(decl(OnClass).bind(
|
||||||
"ptr_to_ptr")))))).bind("smart_pointer")),
|
"ptr_to_ptr")))))).bind("smart_pointer")),
|
||||||
|
unless(callee(memberExpr(hasObjectExpression(thisExpr())))),
|
||||||
callee(methodDecl(hasName("get")))).bind("redundant_get");
|
callee(methodDecl(hasName("get")))).bind("redundant_get");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,16 @@ void Positive() {
|
||||||
// CHECK-NOT: warning
|
// CHECK-NOT: warning
|
||||||
|
|
||||||
void Negative() {
|
void Negative() {
|
||||||
|
struct NegPtr {
|
||||||
|
int* get();
|
||||||
|
int* operator->() {
|
||||||
|
return &*this->get();
|
||||||
|
}
|
||||||
|
int& operator*() {
|
||||||
|
return *get();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
std::unique_ptr<Bar>* u;
|
std::unique_ptr<Bar>* u;
|
||||||
u->get()->Do();
|
u->get()->Do();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue