]> granicus.if.org Git - clang/commitdiff
[analyzer] Add a malloc cpp test file.
authorAnna Zaks <ganna@apple.com>
Thu, 29 Mar 2012 23:26:54 +0000 (23:26 +0000)
committerAnna Zaks <ganna@apple.com>
Thu, 29 Mar 2012 23:26:54 +0000 (23:26 +0000)
Includes a test from a reported false positive fixed in some earlier
commit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153702 91177308-0d34-0410-b5e6-96231b3b80d8

test/Analysis/malloc.cpp [new file with mode: 0644]

diff --git a/test/Analysis/malloc.cpp b/test/Analysis/malloc.cpp
new file mode 100644 (file)
index 0000000..8f80b2b
--- /dev/null
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,experimental.core.CastSize,unix.Malloc -analyzer-store=region -verify %s
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void free(void *);
+void *realloc(void *ptr, size_t size);
+void *calloc(size_t nmemb, size_t size);
+
+// Test for radar://11110132.
+struct Foo {
+    mutable void* m_data;
+    Foo(void* data) : m_data(data) {}
+};
+Foo aFunction() {
+    return malloc(10);
+}