diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:06:01 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:06:01 +0000 |
| commit | 486754660bb926339aefcf012a3f848592babb8b (patch) | |
| tree | ecdbc446c9876f4f120f701c243373cd3cb43db3 /test/CodeGenCXX/alloc-size.cpp | |
| parent | 55e6d896ad333f07bb3b1ba487df214fc268a4ab (diff) | |
Notes
Diffstat (limited to 'test/CodeGenCXX/alloc-size.cpp')
| -rw-r--r-- | test/CodeGenCXX/alloc-size.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/CodeGenCXX/alloc-size.cpp b/test/CodeGenCXX/alloc-size.cpp index e93e231b70e8..e68e52c86bf2 100644 --- a/test/CodeGenCXX/alloc-size.cpp +++ b/test/CodeGenCXX/alloc-size.cpp @@ -69,4 +69,38 @@ int testIt() { __builtin_object_size(dependent_calloc<7, 8>(), 0) + __builtin_object_size(dependent_calloc2<int, 9>(), 0); } +} // namespace templated_alloc_size + +// Be sure that an ExprWithCleanups doesn't deter us. +namespace alloc_size_with_cleanups { +struct Foo { + ~Foo(); +}; + +void *my_malloc(const Foo &, int N) __attribute__((alloc_size(2))); + +// CHECK-LABEL: define i32 @_ZN24alloc_size_with_cleanups6testItEv +int testIt() { + int *const p = (int *)my_malloc(Foo{}, 3); + // CHECK: ret i32 3 + return __builtin_object_size(p, 0); +} +} // namespace alloc_size_with_cleanups + +class C { +public: + void *my_malloc(int N) __attribute__((alloc_size(2))); + void *my_calloc(int N, int M) __attribute__((alloc_size(2, 3))); +}; + +// CHECK-LABEL: define i32 @_Z16callMemberMallocv +int callMemberMalloc() { + // CHECK: ret i32 16 + return __builtin_object_size(C().my_malloc(16), 0); +} + +// CHECK-LABEL: define i32 @_Z16callMemberCallocv +int callMemberCalloc() { + // CHECK: ret i32 32 + return __builtin_object_size(C().my_calloc(16, 2), 0); } |
