aboutsummaryrefslogtreecommitdiff
path: root/test/Analysis/Malloc+NewDelete_intersections.cpp
diff options
context:
space:
mode:
authorAnton Yartsev <anton.yartsev@gmail.com>2013-04-04 23:46:29 +0000
committerAnton Yartsev <anton.yartsev@gmail.com>2013-04-04 23:46:29 +0000
commit648cb71625a2ab3164b2cacac9e9cb3d22b03bd7 (patch)
tree4d407147e1b1d9b2f3fe31d1eca4eb5d80d74e2d /test/Analysis/Malloc+NewDelete_intersections.cpp
parentb0eb771fb5fcbbf283e357f95230adeb6570380f (diff)
[analyzer] Reduced the unwanted correlations between checkers living inside MallocChecker.cpp
This fixes an issue pointed to by Jordan: if unix.Malloc and unix.MismatchedDeallocator are both on, then we end up still tracking leaks of memory allocated by new. Moved the guards right before emitting the bug reports to unify and simplify the logic of handling of multiple checkers. Now all the checkers perform their checks regardless of if they were enabled, or not, and it is decided just before the emitting of the report, if it should be emitted. (idea from Anna). Additional changes: improved test coverage for checker correlations; refactoring: BadDealloc -> MismatchedDealloc git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178814 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/Malloc+NewDelete_intersections.cpp')
-rw-r--r--test/Analysis/Malloc+NewDelete_intersections.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/Analysis/Malloc+NewDelete_intersections.cpp b/test/Analysis/Malloc+NewDelete_intersections.cpp
new file mode 100644
index 0000000000..7a0ef8e13c
--- /dev/null
+++ b/test/Analysis/Malloc+NewDelete_intersections.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,alpha.cplusplus.NewDelete -analyzer-store region -std=c++11 -verify %s
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void free(void *);
+
+//-------------------------------------------------------------------
+// Check that unix.Malloc + alpha.cplusplus.NewDelete does not enable
+// warnings produced by unix.MismatchedDeallocator.
+//-------------------------------------------------------------------
+void testMismatchedDeallocator() {
+ int *p = (int *)malloc(sizeof(int));
+ delete p;
+} // expected-warning{{Memory is never released; potential leak of memory pointed to by 'p'}}