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