forked from OSchip/llvm-project
[Analyzer] Fix for SValBuilder expressions rearrangement
Expression rearrangement in SValBuilder (see rL329780) crashes with an assert if the type of the integer is different from the type of the symbol. This fix adds a check that prevents rearrangement in such cases. Differential Revision: https://reviews.llvm.org/D45557 llvm-svn: 330064
This commit is contained in:
parent
ab40e44ba1
commit
13e186c088
|
@ -469,6 +469,8 @@ static Optional<NonLoc> tryRearrange(ProgramStateRef State,
|
|||
// Initialize SingleTy later with a symbol's type.
|
||||
} else if (BinaryOperator::isAdditiveOp(Op)) {
|
||||
SingleTy = ResultTy;
|
||||
if (LSym->getType() != SingleTy)
|
||||
return None;
|
||||
// Substracting unsigned integers is a nightmare.
|
||||
if (!SingleTy->isSignedIntegerOrEnumerationType())
|
||||
return None;
|
||||
|
|
|
@ -929,3 +929,8 @@ void overflow(signed char n, signed char m) {
|
|||
clang_analyzer_eval(n - 126 == m + 3); // expected-warning{{UNKNOWN}}
|
||||
}
|
||||
}
|
||||
|
||||
int mixed_integer_types(int x, int y) {
|
||||
short a = x - 1U;
|
||||
return a - y;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue