diff options
author | Ted Kremenek <kremenek@apple.com> | 2012-03-16 04:59:57 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2012-03-16 04:59:57 +0000 |
commit | 2befa8c763c84df0aa77f830b1cf530cd0bb987c (patch) | |
tree | df37d47cc5c3b8600538452b8e75e2f25d6a3259 | |
parent | 1425226b66d0b5e46bd78a44cc5c5053cf274a12 (diff) |
Add test case for <rdar://problem/8808566>, which is now fixed by inlining support.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152894 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | test/Analysis/default-analyze.m | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/Analysis/default-analyze.m b/test/Analysis/default-analyze.m index 947cb7fd3d..82656b24a6 100644 --- a/test/Analysis/default-analyze.m +++ b/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; +} |