[analyzer] Introduce CXXAllocatorCall to handle placement arg invalidation.
This is NOT full-blown support for operator new, but removes some nasty
duplicated code introduced in r158784.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159608 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Analysis/new.cpp b/test/Analysis/new.cpp
index 723d033..5dad943 100644
--- a/test/Analysis/new.cpp
+++ b/test/Analysis/new.cpp
@@ -49,6 +49,16 @@
return y; // no-warning
}
+void *operator new(size_t, void *, void *);
+void *testCustomNewMalloc() {
+ int *x = (int *)malloc(sizeof(int));
+
+ // Should be no-warning (the custom allocator could have freed x).
+ void *y = new (0, x) int; // no-warning
+
+ return y;
+}
+
//--------------------------------
// Incorrectly-modelled behavior
@@ -69,14 +79,3 @@
clang_analyzer_eval(*n == 3); // expected-warning{{UNKNOWN}}
}
-
-void *operator new(size_t, void *, void *);
-void *testCustomNewMalloc() {
- int *x = (int *)malloc(sizeof(int));
-
- // Should be no-warning (the custom allocator could have freed x).
- void *y = new (0, x) int; // expected-warning{{leak of memory pointed to by 'x'}}
-
- return y;
-}
-