[cfe-commits] r158165 - in /cfe/trunk: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp test/Analysis/malloc.c
Anna Zaks
ganna at apple.com
Thu Jun 7 13:18:08 PDT 2012
Author: zaks
Date: Thu Jun 7 15:18:08 2012
New Revision: 158165
URL: http://llvm.org/viewvc/llvm-project?rev=158165&view=rev
Log:
[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.
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
cfe/trunk/test/Analysis/malloc.c
Modified: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp?rev=158165&r1=158164&r2=158165&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp Thu Jun 7 15:18:08 2012
@@ -701,7 +701,7 @@
// 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();
Modified: cfe/trunk/test/Analysis/malloc.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/malloc.c?rev=158165&r1=158164&r2=158165&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/malloc.c (original)
+++ cfe/trunk/test/Analysis/malloc.c Thu Jun 7 15:18:08 2012
@@ -902,6 +902,23 @@
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.
More information about the cfe-commits
mailing list