[cfe-commits] r161275 - in /cfe/trunk: lib/AST/ExprCXX.cpp test/Analysis/misc-ps-cxx0x.cpp
Jordan Rose
jordan_rose at apple.com
Fri Aug 3 16:08:39 PDT 2012
Author: jrose
Date: Fri Aug 3 18:08:39 2012
New Revision: 161275
URL: http://llvm.org/viewvc/llvm-project?rev=161275&view=rev
Log:
Enhance getImplicitObjectArgument to look through ->*.
This only applies in the case where ->* is not overloaded, since it
specifically looks for BinaryOperator and not CXXOperatorCallExpr.
Modified:
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/test/Analysis/misc-ps-cxx0x.cpp
Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=161275&r1=161274&r2=161275&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Fri Aug 3 18:08:39 2012
@@ -434,9 +434,12 @@
}
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;
Modified: cfe/trunk/test/Analysis/misc-ps-cxx0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps-cxx0x.cpp?rev=161275&r1=161274&r2=161275&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/misc-ps-cxx0x.cpp (original)
+++ cfe/trunk/test/Analysis/misc-ps-cxx0x.cpp Fri Aug 3 18:08:39 2012
@@ -109,3 +109,10 @@
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}}
+}
+
More information about the cfe-commits
mailing list