forked from OSchip/llvm-project
[analyzer] Avoid crash when attempting to evaluate binary operation on LazyCompoundVal.
Instead, return UnknownValue if either operand is a nonloc::LazyCompoundVal. This is a spot fix for PR 24951. rdar://problem/23682244 llvm-svn: 260066
This commit is contained in:
parent
f1d54eb222
commit
480a0c00ca
|
@ -367,6 +367,11 @@ SVal SValBuilder::evalBinOp(ProgramStateRef state, BinaryOperator::Opcode op,
|
||||||
if (lhs.isUnknown() || rhs.isUnknown())
|
if (lhs.isUnknown() || rhs.isUnknown())
|
||||||
return UnknownVal();
|
return UnknownVal();
|
||||||
|
|
||||||
|
if (lhs.getAs<nonloc::LazyCompoundVal>() ||
|
||||||
|
rhs.getAs<nonloc::LazyCompoundVal>()) {
|
||||||
|
return UnknownVal();
|
||||||
|
}
|
||||||
|
|
||||||
if (Optional<Loc> LV = lhs.getAs<Loc>()) {
|
if (Optional<Loc> LV = lhs.getAs<Loc>()) {
|
||||||
if (Optional<Loc> RV = rhs.getAs<Loc>())
|
if (Optional<Loc> RV = rhs.getAs<Loc>())
|
||||||
return evalBinOpLL(state, op, *LV, *RV, type);
|
return evalBinOpLL(state, op, *LV, *RV, type);
|
||||||
|
|
|
@ -756,6 +756,20 @@ void strcmp_unknown_arg (char *unknown) {
|
||||||
clang_analyzer_eval(strcmp(unknown, unknown) == 0); // expected-warning{{TRUE}}
|
clang_analyzer_eval(strcmp(unknown, unknown) == 0); // expected-warning{{TRUE}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
union argument {
|
||||||
|
char *f;
|
||||||
|
};
|
||||||
|
|
||||||
|
void function_pointer_cast_helper(char **a) {
|
||||||
|
strcmp("Hi", *a); // PR24951 crash
|
||||||
|
}
|
||||||
|
|
||||||
|
void strcmp_union_function_pointer_cast(union argument a) {
|
||||||
|
void (*fPtr)(union argument *) = (void (*)(union argument *))function_pointer_cast_helper;
|
||||||
|
|
||||||
|
fPtr(&a);
|
||||||
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===
|
//===----------------------------------------------------------------------===
|
||||||
// strncmp()
|
// strncmp()
|
||||||
//===----------------------------------------------------------------------===
|
//===----------------------------------------------------------------------===
|
||||||
|
|
Loading…
Reference in New Issue