@@ -1418,14 +1418,19 @@ FindLastStoreBRVisitor::VisitNode(const ExplodedNode *Succ,
1418
1418
if (Optional<CallEnter> CE = Succ->getLocationAs <CallEnter>()) {
1419
1419
if (const auto *VR = dyn_cast<VarRegion>(R)) {
1420
1420
1421
- const auto *Param = cast<ParmVarDecl>(VR->getDecl ());
1421
+ if (const auto *Param = dyn_cast<ParmVarDecl>(VR->getDecl ())) {
1422
+ ProgramStateManager &StateMgr = BRC.getStateManager ();
1423
+ CallEventManager &CallMgr = StateMgr.getCallEventManager ();
1422
1424
1423
- ProgramStateManager &StateMgr = BRC.getStateManager ();
1424
- CallEventManager &CallMgr = StateMgr.getCallEventManager ();
1425
-
1426
- CallEventRef<> Call = CallMgr.getCaller (CE->getCalleeContext (),
1427
- Succ->getState ());
1428
- InitE = Call->getArgExpr (Param->getFunctionScopeIndex ());
1425
+ CallEventRef<> Call = CallMgr.getCaller (CE->getCalleeContext (),
1426
+ Succ->getState ());
1427
+ InitE = Call->getArgExpr (Param->getFunctionScopeIndex ());
1428
+ } else {
1429
+ // Handle Objective-C 'self'.
1430
+ assert (isa<ImplicitParamDecl>(VR->getDecl ()));
1431
+ InitE = cast<ObjCMessageExpr>(CE->getCalleeContext ()->getCallSite ())
1432
+ ->getInstanceReceiver ()->IgnoreParenCasts ();
1433
+ }
1429
1434
IsParam = true ;
1430
1435
}
1431
1436
}
@@ -2029,8 +2034,6 @@ bool bugreporter::trackExpressionValue(const ExplodedNode *InputNode,
2029
2034
2030
2035
// Is it a symbolic value?
2031
2036
if (auto L = V.getAs <loc::MemRegionVal>()) {
2032
- report.addVisitor (llvm::make_unique<UndefOrNullArgVisitor>(L->getRegion ()));
2033
-
2034
2037
// FIXME: this is a hack for fixing a later crash when attempting to
2035
2038
// dereference a void* pointer.
2036
2039
// We should not try to dereference pointers at all when we don't care
@@ -2051,10 +2054,14 @@ bool bugreporter::trackExpressionValue(const ExplodedNode *InputNode,
2051
2054
else if (CanDereference)
2052
2055
RVal = LVState->getSVal (L->getRegion ());
2053
2056
2054
- if (CanDereference)
2057
+ if (CanDereference) {
2058
+ report.addVisitor (
2059
+ std::make_unique<UndefOrNullArgVisitor>(L->getRegion ()));
2060
+
2055
2061
if (auto KV = RVal.getAs <KnownSVal>())
2056
2062
report.addVisitor (llvm::make_unique<FindLastStoreBRVisitor>(
2057
2063
*KV, L->getRegion (), EnableNullFPSuppression, TKind, SFC));
2064
+ }
2058
2065
2059
2066
const MemRegion *RegionRVal = RVal.getAsRegion ();
2060
2067
if (RegionRVal && isa<SymbolicRegion>(RegionRVal)) {
0 commit comments