]> granicus.if.org Git - clang/commitdiff
Add test case for <rdar://problem/8808566>, which is now fixed by inlining support.
authorTed Kremenek <kremenek@apple.com>
Fri, 16 Mar 2012 04:59:57 +0000 (04:59 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 16 Mar 2012 04:59:57 +0000 (04:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152894 91177308-0d34-0410-b5e6-96231b3b80d8

test/Analysis/default-analyze.m

index 947cb7fd3d86908feb02ee3e79d0caf798b054ec..82656b24a6e97dffb4ec1fa581751aecf12e2292 100644 (file)
@@ -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;
+}