diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2013-04-08 18:45:10 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2013-04-08 18:45:10 +0000 |
commit | 809500fc2c13c8173a16b052304d983864e4a1e1 (patch) | |
tree | 4fc2f184c499d106f29a386c452b49e5197bf63d /test/Analysis/malloc.cpp | |
parent | be7c9ec198dcdb5bf73a35bfbb00b3333cb87909 (diff) |
Notes
Diffstat (limited to 'test/Analysis/malloc.cpp')
-rw-r--r-- | test/Analysis/malloc.cpp | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/test/Analysis/malloc.cpp b/test/Analysis/malloc.cpp index 220d74625bc0b..54efa1c2bd794 100644 --- a/test/Analysis/malloc.cpp +++ b/test/Analysis/malloc.cpp @@ -5,11 +5,11 @@ void *malloc(size_t); void free(void *); void *realloc(void *ptr, size_t size); void *calloc(size_t nmemb, size_t size); - +char *strdup(const char *s); void checkThatMallocCheckerIsRunning() { - malloc(4); // expected-warning{{leak}} -} + malloc(4); +} // expected-warning{{leak}} // Test for radar://11110132. struct Foo { @@ -60,3 +60,43 @@ namespace PR13751 { } } +struct X { void *a; }; + +struct X get() { + struct X result; + result.a = malloc(4); + return result; // no-warning +} + +// Ensure that regions accessible through a LazyCompoundVal trigger region escape. +// Malloc checker used to report leaks for the following two test cases. +struct Property { + char* getterName; + Property(char* n) + : getterName(n) {} + +}; +void append(Property x); + +void appendWrapper(char *getterName) { + append(Property(getterName)); +} +void foo(const char* name) { + char* getterName = strdup(name); + appendWrapper(getterName); // no-warning +} + +struct NestedProperty { + Property prop; + NestedProperty(Property p) + : prop(p) {} +}; +void appendNested(NestedProperty x); + +void appendWrapperNested(char *getterName) { + appendNested(NestedProperty(Property(getterName))); +} +void fooNested(const char* name) { + char* getterName = strdup(name); + appendWrapperNested(getterName); // no-warning +}
\ No newline at end of file |