diff options
author | dim <dim@FreeBSD.org> | 2012-08-15 20:02:54 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2012-08-15 20:02:54 +0000 |
commit | 554bcb69c2d785a011a30e7db87a36a87fe7db10 (patch) | |
tree | 9abb1a658a297776086f4e0dfa6ca533de02104e /test/Analysis/malloc.cpp | |
parent | bb67ca86b31f67faee50bd10c3b036d65751745a (diff) | |
download | FreeBSD-src-554bcb69c2d785a011a30e7db87a36a87fe7db10.zip FreeBSD-src-554bcb69c2d785a011a30e7db87a36a87fe7db10.tar.gz |
Vendor import of clang trunk r161861:
http://llvm.org/svn/llvm-project/cfe/trunk@161861
Diffstat (limited to 'test/Analysis/malloc.cpp')
-rw-r--r-- | test/Analysis/malloc.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/Analysis/malloc.cpp b/test/Analysis/malloc.cpp index 8f80b2b..72b9272 100644 --- a/test/Analysis/malloc.cpp +++ b/test/Analysis/malloc.cpp @@ -14,3 +14,24 @@ struct Foo { Foo aFunction() { return malloc(10); } + +// Assume that functions which take a function pointer can free memory even if +// they are defined in system headers and take the const pointer to the +// allocated memory. (radar://11160612) +// Test default parameter. +int const_ptr_and_callback_def_param(int, const char*, int n, void(*)(void*) = 0); +void r11160612_3() { + char *x = (char*)malloc(12); + const_ptr_and_callback_def_param(0, x, 12); +} + +// Test member function pointer. +struct CanFreeMemory { + static void myFree(void*); +}; +//This is handled because we look at the type of the parameter(not argument). +void r11160612_3(CanFreeMemory* p) { + char *x = (char*)malloc(12); + const_ptr_and_callback_def_param(0, x, 12, p->myFree); +} + |