xref: /llvm-project/clang/test/Analysis/analyzer-display-progress.m (revision 32b828306e346bc8e86c0b763f3514329de60ed1)
1// RUN: %clang_analyze_cc1 -fblocks -verify %s 2>&1 \
2// RUN:   -analyzer-display-progress \
3// RUN:   -analyzer-checker=debug.ExprInspection \
4// RUN:   -analyzer-output=text \
5// RUN: | FileCheck %s
6
7#include "Inputs/system-header-simulator-objc.h"
8
9void clang_analyzer_warnIfReached();
10
11// expected-note@+2 {{[debug] analyzing from f}}
12// expected-warning@+1 {{REACHABLE}} expected-note@+1 {{REACHABLE}}
13static void f(void) { clang_analyzer_warnIfReached(); }
14
15@interface I: NSObject
16-(void)instanceMethod:(int)arg1 with:(int)arg2;
17+(void)classMethod;
18@end
19
20@implementation I
21// expected-warning@+1 {{REACHABLE}} expected-note@+1 {{REACHABLE}}
22-(void)instanceMethod:(int)arg1 with:(int)arg2 { clang_analyzer_warnIfReached(); }
23
24// expected-warning@+1 {{REACHABLE}} expected-note@+1 {{REACHABLE}}
25+(void)classMethod { clang_analyzer_warnIfReached(); }
26@end
27
28// expected-note@+1 3 {{[debug] analyzing from g}}
29void g(I *i, int x, int y) {
30  [I classMethod]; // expected-note {{Calling 'classMethod'}}
31  [i instanceMethod: x with: y]; // expected-note {{Calling 'instanceMethod:with:'}}
32
33  void (^block)(void);
34  // expected-warning@+1 {{REACHABLE}} expected-note@+1 {{REACHABLE}}
35  block = ^{ clang_analyzer_warnIfReached(); };
36  block(); // expected-note {{Calling anonymous block}}
37}
38
39// CHECK: analyzer-display-progress.m f
40// CHECK: analyzer-display-progress.m -[I instanceMethod:with:]
41// CHECK: analyzer-display-progress.m +[I classMethod]
42// CHECK: analyzer-display-progress.m g
43// CHECK: analyzer-display-progress.m block (line: 35, col: 11)
44