aboutsummaryrefslogtreecommitdiff
path: root/test/Analysis
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2013-04-02 01:28:24 +0000
committerAnna Zaks <ganna@apple.com>2013-04-02 01:28:24 +0000
commit658a28479dd775f6ff2c07fa5699a7ea01e04127 (patch)
tree93a35f855ff7b50375f72a32c25dc627a1acf3fc /test/Analysis
parent7959194fded7b2b1d37ead268d42c8ae6b10fe25 (diff)
[analyzer] Teach invalidateRegions that regions within LazyCompoundVal need to be invalidated
Refactor invalidateRegions to take SVals instead of Regions as input and teach RegionStore about processing LazyCompoundVal as a top-level “escaping” value. This addresses several false positives that get triggered by the NewDelete checker, but the underlying issue is reproducible with other checkers as well (for example, MallocChecker). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178518 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis')
-rw-r--r--test/Analysis/malloc.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/test/Analysis/malloc.cpp b/test/Analysis/malloc.cpp
index a7c365289f..54efa1c2bd 100644
--- a/test/Analysis/malloc.cpp
+++ b/test/Analysis/malloc.cpp
@@ -5,7 +5,7 @@ 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);
@@ -67,3 +67,36 @@ struct X get() {
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