summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2012-03-16 04:59:57 +0000
committerTed Kremenek <kremenek@apple.com>2012-03-16 04:59:57 +0000
commitc0d0d35117382e33bc8d92f33ad10fe27fba47c5 (patch)
treeeee011425f091e80a4187b56ed8e6098ec5481e1 /clang/test
parent4970ef99fcda862c74a61bc4d664346d2299a305 (diff)
downloadbcm5719-llvm-c0d0d35117382e33bc8d92f33ad10fe27fba47c5.tar.gz
bcm5719-llvm-c0d0d35117382e33bc8d92f33ad10fe27fba47c5.zip
Add test case for <rdar://problem/8808566>, which is now fixed by inlining support.
llvm-svn: 152894
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Analysis/default-analyze.m43
1 files changed, 43 insertions, 0 deletions
diff --git a/clang/test/Analysis/default-analyze.m b/clang/test/Analysis/default-analyze.m
index 947cb7fd3d8..82656b24a6e 100644
--- a/clang/test/Analysis/default-analyze.m
+++ b/clang/test/Analysis/default-analyze.m
@@ -17,4 +17,47 @@ id foo(int x) {
return title;
}
+// <rdar://problem/8808566> Static analyzer is wrong: NSWidth(imgRect) not understood as unconditional assignment
+//
+// Note: this requires inlining support. This previously issued a false positive use of
+// uninitialized value when calling NSWidth.
+typedef double CGFloat;
+
+struct CGPoint {
+ CGFloat x;
+ CGFloat y;
+};
+typedef struct CGPoint CGPoint;
+
+struct CGSize {
+ CGFloat width;
+ CGFloat height;
+};
+typedef struct CGSize CGSize;
+
+struct CGRect {
+ CGPoint origin;
+ CGSize size;
+};
+typedef struct CGRect CGRect;
+
+typedef CGRect NSRect;
+typedef CGSize NSSize;
+
+static __inline__ __attribute__((always_inline)) CGFloat NSWidth(NSRect aRect) {
+ return (aRect.size.width);
+}
+
+static __inline__ __attribute__((always_inline)) CGFloat NSHeight(NSRect aRect) {
+ return (aRect.size.height);
+}
+
+NSSize rdar880566_size();
+
+double rdar8808566() {
+ NSRect myRect;
+ myRect.size = rdar880566_size();
+ double x = NSWidth(myRect) + NSHeight(myRect); // no-warning
+ return x;
+}
OpenPOWER on IntegriCloud