brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · ff58e06 Raw
64 lines · plain
1// RUN: %clang_analyze_cc1 %s -o %t2 3// Tests that some specific checkers are enabled by default.4 5id foo(int x) {6  id title;7  switch (x) {8  case 1:9    title = @"foo"; // expected-warning {{never read}}10  case 2:11    title = @"bar";12    break;13  default:14    title = @"baz";15    break;16  }17  return title;18}19 20// Static analyzer is wrong: NSWidth(imgRect) not understood as unconditional assignment21//22// Note: this requires inlining support.  This previously issued a false positive use of23// uninitialized value when calling NSWidth.24typedef double CGFloat;25 26struct CGPoint {27  CGFloat x;28  CGFloat y;29};30typedef struct CGPoint CGPoint;31 32struct CGSize {33  CGFloat width;34  CGFloat height;35};36typedef struct CGSize CGSize;37 38struct CGRect {39  CGPoint origin;40  CGSize size;41};42typedef struct CGRect CGRect;43 44typedef CGRect NSRect;45typedef CGSize NSSize;46 47static __inline__ __attribute__((always_inline)) CGFloat NSWidth(NSRect aRect) {48    return (aRect.size.width);49}50 51static __inline__ __attribute__((always_inline)) CGFloat NSHeight(NSRect aRect) {52    return (aRect.size.height);53}54 55NSSize rdar880566_size(void);56 57double rdar8808566(void) {58  NSRect myRect;59  myRect.size = rdar880566_size();60  double x = NSWidth(myRect) + NSHeight(myRect); // no-warning61  return x;62}63 64