forked from OSchip/llvm-project
Fix regression introduced in r80786 and reported in PR 4867. We should use
'dyn_cast' instead of 'cast' as the denominator value could be UnknownVal (and is not guaranteed to be a DefinedVal). llvm-svn: 80869
This commit is contained in:
parent
f7188325ef
commit
b117fd9168
|
@ -716,11 +716,16 @@ void CheckBadDiv::PreVisitBinaryOperator(CheckerContext &C,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle the case where 'Denom' is UnknownVal.
|
||||||
|
const DefinedSVal *DV = dyn_cast<DefinedSVal>(&Denom);
|
||||||
|
|
||||||
|
if (!DV)
|
||||||
|
return;
|
||||||
|
|
||||||
// Check for divide by zero.
|
// Check for divide by zero.
|
||||||
ConstraintManager &CM = C.getConstraintManager();
|
ConstraintManager &CM = C.getConstraintManager();
|
||||||
const GRState *stateNotZero, *stateZero;
|
const GRState *stateNotZero, *stateZero;
|
||||||
llvm::tie(stateNotZero, stateZero) = CM.AssumeDual(C.getState(),
|
llvm::tie(stateNotZero, stateZero) = CM.AssumeDual(C.getState(), *DV);
|
||||||
cast<DefinedSVal>(Denom));
|
|
||||||
|
|
||||||
if (stateZero && !stateNotZero) {
|
if (stateZero && !stateNotZero) {
|
||||||
if (ExplodedNode *N = C.GenerateNode(B, stateZero, true)) {
|
if (ExplodedNode *N = C.GenerateNode(B, stateZero, true)) {
|
||||||
|
|
Loading…
Reference in New Issue