[analyzer] Fixit for r158136.

I falsely assumed that the memory spaces are equal when we reach this
point, they might not be when memory space of one or more is stack or
Unknown. We don't want a region from Heap space alias something with
another memory space.

llvm-svn: 158165
This commit is contained in:
Anna Zaks 2012-06-07 20:18:08 +00:00
parent a5d24ca453
commit a7dcc996a9
2 changed files with 18 additions and 1 deletions

View File

@ -701,7 +701,7 @@ SVal SimpleSValBuilder::evalBinOpLL(ProgramStateRef state,
// on each invocation.
if (LeftBase != RightBase &&
((!isa<SymbolicRegion>(LeftBase) && !isa<SymbolicRegion>(RightBase)) ||
isa<HeapSpaceRegion>(LeftMS)) ){
(isa<HeapSpaceRegion>(LeftMS) || isa<HeapSpaceRegion>(RightMS))) ){
switch (op) {
default:
return UnknownVal();

View File

@ -902,6 +902,23 @@ int HeapAssignment() {
return 0;
}
int *retPtr();
int *retPtrMightAlias(int *x);
int cmpHeapAllocationToUnknown() {
int zero = 0;
int *yBefore = retPtr();
int *m = malloc(8);
int *yAfter = retPtrMightAlias(m);
if (yBefore == m) {
return 5/zero; // expected-warning {{This statement is never executed}}
}
if (yAfter == m) {
return 5/zero; // expected-warning {{This statement is never executed}}
}
free(m);
return 0;
}
// ----------------------------------------------------------------------------
// False negatives.