aboutsummaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer/Core
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2012-08-06 23:25:39 +0000
committerAnna Zaks <ganna@apple.com>2012-08-06 23:25:39 +0000
commitc7ecc43c33a21b82c49664910b19fcc1f555aa51 (patch)
treee08d07f14729a8c26fe7852b8424d0328811b179 /lib/StaticAnalyzer/Core
parent71f55f771794674a410171dbf3cb5dbedf95d033 (diff)
[analyzer] Add a checker to manage dynamic type propagation.
Instead of sprinkling dynamic type info propagation throughout ExprEngine, the added checker would add the more precise type information on known APIs (Ex: ObjC alloc, new) and propagate the type info in other cases (ex: ObjC init method, casts (the second is not implemented yet)). Add handling of ObjC alloc, new and init to the checker. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161357 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core')
-rw-r--r--lib/StaticAnalyzer/Core/CallEvent.cpp9
-rw-r--r--lib/StaticAnalyzer/Core/ExprEngineC.cpp3
-rw-r--r--lib/StaticAnalyzer/Core/ProgramState.cpp4
3 files changed, 6 insertions, 10 deletions
diff --git a/lib/StaticAnalyzer/Core/CallEvent.cpp b/lib/StaticAnalyzer/Core/CallEvent.cpp
index 05147670c1..396e0f6d8d 100644
--- a/lib/StaticAnalyzer/Core/CallEvent.cpp
+++ b/lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -583,8 +583,8 @@ SVal ObjCMethodCall::getReceiverSVal() const {
if (!isInstanceMessage())
return UnknownVal();
- if (const Expr *Base = getOriginExpr()->getInstanceReceiver())
- return getSVal(Base);
+ if (const Expr *RecE = getOriginExpr()->getInstanceReceiver())
+ return getSVal(RecE);
// An instance message with no expression means we are sending to super.
// In this case the object reference is the same as 'self'.
@@ -676,8 +676,8 @@ const Decl *ObjCMethodCall::getRuntimeDefinition() const {
if (!Receiver)
return 0;
- DynamicTypeInfo TI = getState()->getDynamicTypeInfo(Receiver);
- ReceiverT = dyn_cast<ObjCObjectPointerType>(TI.getType().getTypePtr());
+ QualType DynType = getState()->getDynamicTypeInfo(Receiver).getType();
+ ReceiverT = dyn_cast<ObjCObjectPointerType>(DynType.getTypePtr());
}
// Lookup the method implementation.
@@ -715,7 +715,6 @@ void ObjCMethodCall::getInitialStackFrameContents(
}
}
-
CallEventRef<SimpleCall>
CallEventManager::getSimpleCall(const CallExpr *CE, ProgramStateRef State,
const LocationContext *LCtx) {
diff --git a/lib/StaticAnalyzer/Core/ExprEngineC.cpp b/lib/StaticAnalyzer/Core/ExprEngineC.cpp
index 740dec5ec4..7ec151ef6d 100644
--- a/lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ b/lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -308,9 +308,6 @@ void ExprEngine::VisitCast(const CastExpr *CastE, const Expr *Ex,
const LocationContext *LCtx = Pred->getLocationContext();
SVal V = state->getSVal(Ex, LCtx);
V = svalBuilder.evalCast(V, T, ExTy);
- if (const MemRegion *R = V.getAsRegion()) {
- state = state->addDynamicTypeInfo(R, T);
- }
state = state->BindExpr(CastE, LCtx, V);
Bldr.generateNode(CastE, Pred, state);
continue;
diff --git a/lib/StaticAnalyzer/Core/ProgramState.cpp b/lib/StaticAnalyzer/Core/ProgramState.cpp
index b44c470a90..c916c1a020 100644
--- a/lib/StaticAnalyzer/Core/ProgramState.cpp
+++ b/lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -762,12 +762,12 @@ DynamicTypeInfo ProgramState::getDynamicTypeInfo(const MemRegion *Reg) const {
}
ProgramStateRef ProgramState::addDynamicTypeInfo(const MemRegion *Reg,
- QualType NewTy) const {
+ DynamicTypeInfo NewTy) const {
if (const SymbolicRegion *SR = dyn_cast<SymbolicRegion>(Reg)) {
SymbolRef Sym = SR->getSymbol();
// TODO: Instead of resetting the type info, check the old type info and
// merge and pick the most precise type.
- ProgramStateRef NewState = set<DynamicTypeMap>(Sym, DynamicTypeInfo(NewTy));
+ ProgramStateRef NewState = set<DynamicTypeMap>(Sym, NewTy);
assert(NewState);
return NewState;
}