[cfe-commits] r141312 - in /cfe/trunk: lib/Analysis/LiveVariables.cpp lib/StaticAnalyzer/Core/ObjCMessage.cpp test/Analysis/misc-ps-cxx0x.cpp
Ted Kremenek
kremenek at apple.com
Thu Oct 6 13:53:29 PDT 2011
Author: kremenek
Date: Thu Oct 6 15:53:28 2011
New Revision: 141312
URL: http://llvm.org/viewvc/llvm-project?rev=141312&view=rev
Log:
[static analyzer] Fix crash in LiveVariables and Environment::getSVal() when analyzing C++ pointer-to-member calls. Fixes <rdar://problem/10243398>.
Modified:
cfe/trunk/lib/Analysis/LiveVariables.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ObjCMessage.cpp
cfe/trunk/test/Analysis/misc-ps-cxx0x.cpp
Modified: cfe/trunk/lib/Analysis/LiveVariables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/LiveVariables.cpp?rev=141312&r1=141311&r2=141312&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/LiveVariables.cpp (original)
+++ cfe/trunk/lib/Analysis/LiveVariables.cpp Thu Oct 6 15:53:28 2011
@@ -352,9 +352,10 @@
case Stmt::CXXMemberCallExprClass: {
// Include the implicit "this" pointer as being live.
CXXMemberCallExpr *CE = cast<CXXMemberCallExpr>(S);
- val.liveStmts =
- LV.SSetFact.add(val.liveStmts,
- CE->getImplicitObjectArgument()->IgnoreParens());
+ if (Expr *ImplicitObj = CE->getImplicitObjectArgument()) {
+ ImplicitObj = ImplicitObj->IgnoreParens();
+ val.liveStmts = LV.SSetFact.add(val.liveStmts, ImplicitObj);
+ }
break;
}
case Stmt::DeclStmtClass: {
Modified: cfe/trunk/lib/StaticAnalyzer/Core/ObjCMessage.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ObjCMessage.cpp?rev=141312&r1=141311&r2=141312&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ObjCMessage.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ObjCMessage.cpp Thu Oct 6 15:53:28 2011
@@ -148,7 +148,13 @@
const CallExpr *ActualCall = CallE.get<const CallExpr *>();
const Expr *callee =
cast<CXXMemberCallExpr>(ActualCall)->getImplicitObjectArgument();
- return State->getSVal(callee);
+
+ // FIXME: Will eventually need to cope with member pointers. This is
+ // a limitation in getImplicitObjectArgument().
+ if (!callee)
+ return UnknownVal();
+
+ return State->getSVal(callee);
}
SVal
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=141312&r1=141311&r2=141312&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/misc-ps-cxx0x.cpp (original)
+++ cfe/trunk/test/Analysis/misc-ps-cxx0x.cpp Thu Oct 6 15:53:28 2011
@@ -9,3 +9,15 @@
*p = 0xDEADBEEF; // expected-warning {{null}}
}
+// Test that pointer-to-member functions don't cause the analyzer
+// to crash.
+struct RDar10243398 {
+ void bar(int x);
+};
+
+typedef void (RDar10243398::*RDar10243398MemberFn)(int x);
+
+void test_rdar10243398(RDar10243398 *p) {
+ RDar10243398MemberFn q = &RDar10243398::bar;
+ ((*p).*(q))(1);
+}
More information about the cfe-commits
mailing list