[cfe-commits] r80700 - /cfe/trunk/test/Analysis/retain-release.m

Daniel Dunbar daniel at zuster.org
Sun Sep 20 00:13:55 PDT 2009


Hi Ted,

On Tue, Sep 1, 2009 at 11:33 AM, Ted Kremenek <kremenek at apple.com> wrote:
> Author: kremenek
> Date: Tue Sep  1 13:33:16 2009
> New Revision: 80700
>
> URL: http://llvm.org/viewvc/llvm-project?rev=80700&view=rev
> Log:
> Add test case from <rdar://problem/7184450>.

This is a super nit-pick, but could these tests be more reduced?

The problem with auto reduced test cases which aren't reduced to the
real bug is that they are hard to read, but the real issue is that
because the test case doesn't *really* show the problem, when things
change in the future and a test needs updating, it can be impossible
to tell whether it is testing what it is supposed to anymore.

I realize this isn't always possible, though, which is why I put it in
the super nit-pick category. It sure would be nice if someone wrote a
super fancy clang based delta tool... :)

 - Daniel

> Modified:
>    cfe/trunk/test/Analysis/retain-release.m
>
> Modified: cfe/trunk/test/Analysis/retain-release.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/retain-release.m?rev=80700&r1=80699&r2=80700&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/Analysis/retain-release.m (original)
> +++ cfe/trunk/test/Analysis/retain-release.m Tue Sep  1 13:33:16 2009
> @@ -229,6 +229,29 @@
>  @protocol ICScannerDeviceDelegate <ICDeviceDelegate>  @optional       - (void)scannerDeviceDidBecomeAvailable:(ICScannerDevice*)scanner;
>  @end
>
> +typedef long unsigned int __darwin_size_t;
> +typedef __darwin_size_t size_t;
> +typedef unsigned long CFTypeID;
> +struct CGPoint {
> +  CGFloat x;
> +  CGFloat y;
> +};
> +typedef struct CGPoint CGPoint;
> +typedef struct CGGradient *CGGradientRef;
> +typedef uint32_t CGGradientDrawingOptions;
> +extern CFTypeID CGGradientGetTypeID(void);
> +extern CGGradientRef CGGradientCreateWithColorComponents(CGColorSpaceRef
> +  space, const CGFloat components[], const CGFloat locations[], size_t count);
> +extern CGGradientRef CGGradientCreateWithColors(CGColorSpaceRef space,
> +  CFArrayRef colors, const CGFloat locations[]);
> +extern CGGradientRef CGGradientRetain(CGGradientRef gradient);
> +extern void CGGradientRelease(CGGradientRef gradient);
> +typedef struct CGContext *CGContextRef;
> +extern void CGContextDrawLinearGradient(CGContextRef context,
> +    CGGradientRef gradient, CGPoint startPoint, CGPoint endPoint,
> +    CGGradientDrawingOptions options);
> +extern CGColorSpaceRef CGColorSpaceCreateDeviceRGB(void);
> +
>  //===----------------------------------------------------------------------===//
>  // Test cases.
>  //===----------------------------------------------------------------------===//
> @@ -898,6 +921,52 @@
>  }
>
>  //===----------------------------------------------------------------------===//
> +// Test of handling CGGradientXXX functions.
> +//===----------------------------------------------------------------------===//
> +
> +void rdar_7184450(CGContextRef myContext, CGFloat x, CGPoint myStartPoint,
> +                  CGPoint myEndPoint) {
> +  size_t num_locations = 6;
> +  CGFloat locations[6] = { 0.0, 0.265, 0.28, 0.31, 0.36, 1.0 };
> +  CGFloat components[28] = { 239.0/256.0, 167.0/256.0, 170.0/256.0,
> +     x,  // Start color
> +    207.0/255.0, 39.0/255.0, 39.0/255.0, x,
> +    147.0/255.0, 21.0/255.0, 22.0/255.0, x,
> +    175.0/255.0, 175.0/255.0, 175.0/255.0, x,
> +    255.0/255.0,255.0/255.0, 255.0/255.0, x,
> +    255.0/255.0,255.0/255.0, 255.0/255.0, x
> +  }; // End color
> +
> +  CGGradientRef myGradient =
> +    CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), // expected-warning{{leak}}
> +      components, locations, num_locations);
> +
> +  CGContextDrawLinearGradient(myContext, myGradient, myStartPoint, myEndPoint,
> +                              0);
> +  CGGradientRelease(myGradient);
> +}
> +
> +void rdar_7184450_pos(CGContextRef myContext, CGFloat x, CGPoint myStartPoint,
> +                  CGPoint myEndPoint) {
> +  size_t num_locations = 6;
> +  CGFloat locations[6] = { 0.0, 0.265, 0.28, 0.31, 0.36, 1.0 };
> +  CGFloat components[28] = { 239.0/256.0, 167.0/256.0, 170.0/256.0,
> +     x,  // Start color
> +    207.0/255.0, 39.0/255.0, 39.0/255.0, x,
> +    147.0/255.0, 21.0/255.0, 22.0/255.0, x,
> +    175.0/255.0, 175.0/255.0, 175.0/255.0, x,
> +    255.0/255.0,255.0/255.0, 255.0/255.0, x,
> +    255.0/255.0,255.0/255.0, 255.0/255.0, x
> +  }; // End color
> +
> +  CGGradientRef myGradient =
> +   CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), components, locations, num_locations); // expected-warning 2 {{leak}}
> +
> +  CGContextDrawLinearGradient(myContext, myGradient, myStartPoint, myEndPoint,
> +                              0);
> +}
> +
> +//===----------------------------------------------------------------------===//
>  // Tests of ownership attributes.
>  //===----------------------------------------------------------------------===//
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>




More information about the cfe-commits mailing list