From 2befa8c763c84df0aa77f830b1cf530cd0bb987c Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Fri, 16 Mar 2012 04:59:57 +0000 Subject: [PATCH] Add test case for , which is now fixed by inlining support. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152894 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Analysis/default-analyze.m | 43 +++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) 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; } +// 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; +} -- 2.50.1