summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-11-06 20:32:38 +0000
committerTed Kremenek <kremenek@apple.com>2009-11-06 20:32:38 +0000
commite3423e84a944b0da0e614a260b611c0955f5dbd0 (patch)
tree8061aac8968d00895240e880fc7954e3d9ec7254
parentdf9ca633b669374a75a1e09ec5d77c185200142e (diff)
downloadbcm5719-llvm-e3423e84a944b0da0e614a260b611c0955f5dbd0.tar.gz
bcm5719-llvm-e3423e84a944b0da0e614a260b611c0955f5dbd0.zip
testing: Merge PR3135.c into misc-ps-region-store.m.
llvm-svn: 86286
-rw-r--r--clang/test/Analysis/PR3135.c20
-rw-r--r--clang/test/Analysis/misc-ps-region-store.m16
2 files changed, 16 insertions, 20 deletions
diff --git a/clang/test/Analysis/PR3135.c b/clang/test/Analysis/PR3135.c
deleted file mode 100644
index 1fca57b47b5..00000000000
--- a/clang/test/Analysis/PR3135.c
+++ /dev/null
@@ -1,20 +0,0 @@
-// RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -verify %s
-// PR3135
-
-typedef struct {
- int *a;
-} structure;
-
-int bar(structure *x);
-
-int foo()
-{
- int x;
- structure y = {&x};
-
- // the call to bar may initialize x
- if (bar(&y) && x) // no-warning
- return 1;
-
- return 0;
-}
diff --git a/clang/test/Analysis/misc-ps-region-store.m b/clang/test/Analysis/misc-ps-region-store.m
index 90242abbbd5..45eb4a252c2 100644
--- a/clang/test/Analysis/misc-ps-region-store.m
+++ b/clang/test/Analysis/misc-ps-region-store.m
@@ -454,3 +454,19 @@ int *test_cwe466_return_outofbounds_pointer() {
return p; // expected-warning{{Returned pointer value points outside the original object}}
}
+//===----------------------------------------------------------------------===//
+// PR 3135 - Test case that shows that a variable may get invalidated when its
+// address is included in a structure that is passed-by-value to an unknown function.
+//===----------------------------------------------------------------------===//
+
+typedef struct { int *a; } pr3135_structure;
+int pr3135_bar(pr3135_structure *x);
+int pr3135() {
+ int x;
+ pr3135_structure y = { &x };
+ // the call to pr3135_bar may initialize x
+ if (pr3135_bar(&y) && x) // no-warning
+ return 1;
+ return 0;
+}
+
OpenPOWER on IntegriCloud