if (StoredVal != Val)
escapes = (State == (State->bindLoc(*regionLoc, Val)));
}
+ if (!escapes) {
+ // Case 4: We do not currently model what happens when a symbol is
+ // assigned to a struct field, so be conservative here and let the symbol
+ // go. TODO: This could definitely be improved upon.
+ escapes = !isa<VarRegion>(regionLoc->getRegion());
+ }
}
// If our store can represent the binding and we aren't storing to something
myglobalpointer = my_malloc(12); // no-warning
}
-void af1_d() {
- struct stuff mystuff;
- mystuff.somefield = my_malloc(12);
-} // expected-warning{{Memory is never released; potential leak}}
-
// Test that we can pass out allocated memory via pointer-to-pointer.
void af1_e(void **pp) {
*pp = my_malloc(42); // no-warning
my_freeBoth(p, q);
}
+// ----------------------------------------------------------------------------
+
+// False negatives.
+
+// Pending on removal of the escaping on assignment to struct fields.
+void af1_d() {
+ struct stuff mystuff;
+ mystuff.somefield = my_malloc(12);
+} // missing warning
+
+
return y; // no-warning
}
-void testStructLeak() {
- StructWithPtr St;
- St.memP = malloc(12);
- return; // expected-warning {{Memory is never released; potential leak of memory pointed to by 'St.memP'}}
-}
-
void testElemRegion1() {
char *x = (void*)malloc(2);
int *ix = (int*)x;
return 0;
}
-void localArrayTest() {
- char *p = (char*)malloc(12);
- char *ArrayL[12];
- ArrayL[0] = p;
-} // expected-warning {{leak}}
-
-void localStructTest() {
- StructWithPtr St;
- StructWithPtr *pSt = &St;
- pSt->memP = malloc(12);
-} // expected-warning{{Memory is never released; potential leak}}
-
#ifdef __INTPTR_TYPE__
// Test double assignment through integers.
typedef __INTPTR_TYPE__ intptr_t;
void testMallocWithParam_2(int **p) {
*p = (int*) malloc(sizeof(int));
}
+
+// Pending on removal of the escaping on assignment to struct fields.
+void testStructLeak() {
+ StructWithPtr St;
+ St.memP = malloc(12);
+ return; // missing warning
+}
+
+void localArrayTest() {
+ char *p = (char*)malloc(12);
+ char *ArrayL[12];
+ ArrayL[0] = p;
+} // missing warning
+
+void localStructTest() {
+ StructWithPtr St;
+ StructWithPtr *pSt = &St;
+ pSt->memP = malloc(12);
+} // missing warning
+
+
+