xref: /minix3/external/bsd/llvm/dist/clang/test/Analysis/live-variables.m (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc// RUN: %clang_cc1 -analyze -analyzer-checker=core -fobjc-arc -verify %s
2*0a6a1f1dSLionel Sambuc// expected-no-diagnostics
3*0a6a1f1dSLionel Sambuc@interface NSObject
4*0a6a1f1dSLionel Sambuc@end
5*0a6a1f1dSLionel Sambuc@interface NSString : NSObject
6*0a6a1f1dSLionel Sambuc- (id)lastPathComponent;
7*0a6a1f1dSLionel Sambuc@end
8*0a6a1f1dSLionel Sambucint getBool();
9*0a6a1f1dSLionel Sambucint *getPtr();
10*0a6a1f1dSLionel Sambucint foo() {
11*0a6a1f1dSLionel Sambuc  int r = 0;
12*0a6a1f1dSLionel Sambuc  NSString *filename = @"filename";
13*0a6a1f1dSLionel Sambuc  for (int x = 0; x< 10; x++) {
14*0a6a1f1dSLionel Sambuc    int *p = getPtr();
15*0a6a1f1dSLionel Sambuc    // Liveness info is not computed correctly due to the following expression.
16*0a6a1f1dSLionel Sambuc    // This happens due to CFG being special cased for short circuit operators.
17*0a6a1f1dSLionel Sambuc    // Note, due to ObjC method call, the outermost logical operator is wrapped in ExprWithCleanups.
18*0a6a1f1dSLionel Sambuc    // PR18159
19*0a6a1f1dSLionel Sambuc    if ((p != 0) && (getBool()) && ([filename lastPathComponent]) && (getBool())) {
20*0a6a1f1dSLionel Sambuc      r = *p; // no-warning
21*0a6a1f1dSLionel Sambuc    }
22*0a6a1f1dSLionel Sambuc  }
23*0a6a1f1dSLionel Sambuc  return r;
24*0a6a1f1dSLionel Sambuc}