summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/malloc.c
diff options
context:
space:
mode:
authorArtem Dergachev <artem.dergachev@gmail.com>2019-04-03 18:21:16 +0000
committerArtem Dergachev <artem.dergachev@gmail.com>2019-04-03 18:21:16 +0000
commit3d90e7e8db2c522c87f0fbfcdcb9aeed62680922 (patch)
tree32fcd49ab9ea9d85079d3a5eea2a42046fb843da /clang/test/Analysis/malloc.c
parent1362d7ef885d1e8136e19d85c0eeba3477b53020 (diff)
downloadbcm5719-llvm-3d90e7e8db2c522c87f0fbfcdcb9aeed62680922.tar.gz
bcm5719-llvm-3d90e7e8db2c522c87f0fbfcdcb9aeed62680922.zip
Revert "[analyzer] Toning down invalidation a bit".
This reverts commit r352473. The overall idea is great, but it seems to cause unintented consequences when not only Region Store invalidation but also pointer escape mechanism was accidentally affected. Based on discussions in https://reviews.llvm.org/D58121#1452483 and https://reviews.llvm.org/D57230#1434161 Differential Revision: https://reviews.llvm.org/D57230 llvm-svn: 357620
Diffstat (limited to 'clang/test/Analysis/malloc.c')
-rw-r--r--clang/test/Analysis/malloc.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/clang/test/Analysis/malloc.c b/clang/test/Analysis/malloc.c
index cbc21b492e5..5288e21a282 100644
--- a/clang/test/Analysis/malloc.c
+++ b/clang/test/Analysis/malloc.c
@@ -1758,8 +1758,8 @@ void constEscape(const void *ptr);
void testConstEscapeThroughAnotherField() {
struct IntAndPtr s;
s.p = malloc(sizeof(int));
- constEscape(&(s.x));
-} // expected-warning {{Potential leak of memory pointed to by 's.p'}}
+ constEscape(&(s.x)); // could free s->p!
+} // no-warning
// PR15623
int testNoCheckerDataPropogationFromLogicalOpOperandToOpResult(void) {
@@ -1812,6 +1812,22 @@ void testLivenessBug(struct B *in_b) {
livenessBugRealloc(b->a);
}
+struct ListInfo {
+ struct ListInfo *next;
+};
+
+struct ConcreteListItem {
+ struct ListInfo li;
+ int i;
+};
+
+void list_add(struct ListInfo *list, struct ListInfo *item);
+
+void testCStyleListItems(struct ListInfo *list) {
+ struct ConcreteListItem *x = malloc(sizeof(struct ConcreteListItem));
+ list_add(list, &x->li); // will free 'x'.
+}
+
// ----------------------------------------------------------------------------
// False negatives.
OpenPOWER on IntegriCloud