Enhance getImplicitObjectArgument to look through ->*.

This only applies in the case where ->* is not overloaded, since it
specifically looks for BinaryOperator and not CXXOperatorCallExpr.

llvm-svn: 161275
This commit is contained in:
Jordan Rose 2012-08-03 23:08:39 +00:00
parent 86bedb0de0
commit 16fe35eb2b
2 changed files with 12 additions and 2 deletions

View File

@ -434,9 +434,12 @@ SourceRange CXXOperatorCallExpr::getSourceRangeImpl() const {
}
Expr *CXXMemberCallExpr::getImplicitObjectArgument() const {
if (const MemberExpr *MemExpr =
dyn_cast<MemberExpr>(getCallee()->IgnoreParens()))
const Expr *Callee = getCallee()->IgnoreParens();
if (const MemberExpr *MemExpr = dyn_cast<MemberExpr>(Callee))
return MemExpr->getBase();
if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(Callee))
if (BO->getOpcode() == BO_PtrMemD || BO->getOpcode() == BO_PtrMemI)
return BO->getLHS();
// FIXME: Will eventually need to cope with member pointers.
return 0;

View File

@ -109,3 +109,10 @@ void test_ic_null(TestInstanceCall *p) {
p->foo(); // expected-warning {{Called C++ object pointer is null}}
}
void test_ic_member_ptr() {
TestInstanceCall *p = 0;
typedef void (TestInstanceCall::*IC_Ptr)();
IC_Ptr bar = &TestInstanceCall::foo;
(p->*bar)(); // expected-warning {{Called C++ object pointer is null}}
}