llvm-project/clang/test/Analysis/ftime-trace-removeDead.cpp
Arseniy Zaostrovnykh f5c4f271ab
[analyzer] Add -ftime-trace scopes for region-store bindings and removeDead (#125884)
From investigation of a few slow analysis cases, I discovered that
`RegionStoreManager::bind*` and `ExprEngine::removeDead` are often the
slowest actions. This change adds explicit scope to the time trace
generated by `-ftime-trace` to enable easy diagnostics of the cases when
these functions are the slowdown culprits.

--
CPP-6109
2025-02-06 16:09:14 +01:00

18 lines
613 B
C++

// 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 one scope for removeDead:
//
// CHECK: "name": "ExprEngine::removeDead"
bool coin();
int f() {
int x = 0;
int y = 0;
while (coin()) {
x = 1;
}
return x / y; // expected-warning{{Division by zero}}
}