aboutsummaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-04-11 22:22:05 +0000
committerTed Kremenek <kremenek@apple.com>2011-04-11 22:22:05 +0000
commit9fec9b1fbd32e71ce8acb701165fd6649b3d8285 (patch)
treebe0f7b849e2ee77a96d710daa3a6046163e6c7b2 /lib/StaticAnalyzer
parentd762357055f3d82959604743dbff20ca337e04be (diff)
C++ static analysis: also invalidate fields of objects that are the callees in C++ method calls.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129308 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer')
-rw-r--r--lib/StaticAnalyzer/Core/CFRefCount.cpp8
-rw-r--r--lib/StaticAnalyzer/Core/ObjCMessage.cpp9
2 files changed, 16 insertions, 1 deletions
diff --git a/lib/StaticAnalyzer/Core/CFRefCount.cpp b/lib/StaticAnalyzer/Core/CFRefCount.cpp
index 5131c73925..df82c58204 100644
--- a/lib/StaticAnalyzer/Core/CFRefCount.cpp
+++ b/lib/StaticAnalyzer/Core/CFRefCount.cpp
@@ -2529,6 +2529,14 @@ void CFRefCount::evalSummary(ExplodedNodeSet& Dst,
RegionsToInvalidate.push_back(region);
}
+ // Invalidate all instance variables for the callee of a C++ method call.
+ // FIXME: We should be able to do better with inter-procedural analysis.
+ // FIXME: we can probably do better for const versus non-const methods.
+ if (callOrMsg.isCXXCall()) {
+ if (const MemRegion *callee = callOrMsg.getCXXCallee().getAsRegion())
+ RegionsToInvalidate.push_back(callee);
+ }
+
for (unsigned idx = 0, e = callOrMsg.getNumArgs(); idx != e; ++idx) {
SVal V = callOrMsg.getArgSValAsScalarOrLoc(idx);
SymbolRef Sym = V.getAsLocSymbol();
diff --git a/lib/StaticAnalyzer/Core/ObjCMessage.cpp b/lib/StaticAnalyzer/Core/ObjCMessage.cpp
index c44d36ae49..c005819c9c 100644
--- a/lib/StaticAnalyzer/Core/ObjCMessage.cpp
+++ b/lib/StaticAnalyzer/Core/ObjCMessage.cpp
@@ -111,7 +111,7 @@ const Expr *ObjCMessage::getArgExpr(unsigned i) const {
QualType CallOrObjCMessage::getResultType(ASTContext &ctx) const {
QualType resultTy;
bool isLVal = false;
-
+
if (CallE) {
isLVal = CallE->isLValue();
const Expr *Callee = CallE->getCallee();
@@ -140,3 +140,10 @@ SVal CallOrObjCMessage::getArgSValAsScalarOrLoc(unsigned i) const {
return Msg.getArgSVal(i, State);
return UnknownVal();
}
+
+SVal CallOrObjCMessage::getCXXCallee() const {
+ assert(isCXXCall());
+ const Expr *callee =
+ cast<CXXMemberCallExpr>(CallE)->getImplicitObjectArgument();
+ return State->getSVal(callee);
+}