1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
// RUN: %clang_analyze_cc1 -analyzer-checker=core %s -ftime-trace=%t.raw.json -ftime-trace-granularity=0 -verify
// RUN: %python -c 'import json, sys; print(json.dumps(json.load(sys.stdin), indent=4))' < %t.raw.json > %t.formatted.json
// RUN: FileCheck --input-file=%t.formatted.json --check-prefix=CHECK %s
// The trace file is rather large, but it should contain at least the duration of the analysis of 'f':
//
// CHECK: "name": "HandleCode f",
// CHECK-NEXT: "args": {
// CHECK-NEXT: "detail": "f()",
// CHECK-NEXT: "file": "{{.+}}ftime-trace.cpp",
// CHECK-NEXT: "line": {{[0-9]+}}
// CHECK-NEXT: }
// If any reports are found, "flushing" their equivalence class (EQC) is a separate action:
//
// CHECK: "name": "Flushing EQC Division by zero",
// CHECK-NEXT: "args": {
// CHECK-NEXT: "detail": "core.DivideZero",
// CHECK-NEXT: "file": "{{.+}}ftime-trace.cpp",
// CHECK-NEXT: "line": {{[0-9]+}}
// CHECK-NEXT: }
// The trace also contains durations of each step, but they are so short that they are not reliably present
// in each run. However, they are also aggregated into Total *, for example:
//
// CHECK: "name": "Total dispatchWorkItem PostStmt",
// CHECK-NEXT: "args": {
// CHECK-NEXT: "count": {{[0-9]+}},
// CHECK-NEXT: "avg ms": {{[0-9]+}}
// CHECK-NEXT: }
// Additionally, the trace lists checker hook points (again, relying on totals here):
//
// CHECK: "name": "Total CheckerManager::runCheckersForStmt (Pre)",
// CHECK-NEXT: "args": {
// CHECK-NEXT: "count": {{[0-9]+}},
// CHECK-NEXT: "avg ms": {{[0-9]+}}
// CHECK-NEXT: }
// Finally, each checker call back is also present:
//
// CHECK: "name": "Total Stmt:DivZeroChecker",
// CHECK-NEXT: "args": {
// CHECK-NEXT: "count": {{[0-9]+}},
// CHECK-NEXT: "avg ms": {{[0-9]+}}
// CHECK-NEXT: }
bool coin();
int f() {
int x = 0;
int y = 0;
while (coin()) {
x = 1;
}
return x / y; // expected-warning{{Division by zero}}
}
|