Skip to content

Commit 670b358

Browse files
committed
Fix test
1 parent 342ef04 commit 670b358

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed
Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,58 @@
1-
// RUN: %clang_analyze_cc1 -std=c++23 -analyzer-checker=core,debug.ExprInspection -verify %s
1+
// RUN: %clang_analyze_cc1 -std=c++23 -triple x86_64-pc-linux-gnu \
2+
// RUN: -analyzer-checker=core,debug.ExprInspection -verify %s
23

34
template <typename T> void clang_analyzer_dump(T);
45
template <typename T> void clang_analyzer_value(T);
56

67
int ternary_in_builtin_assume(int a, int b) {
7-
88
__builtin_assume(a > 10 ? b == 4 : b == 10);
99

10-
clang_analyzer_value(a); // we should have 2 dumps here. expected-warning{{[-2147483648, 10]}} expected-warning{{[11, 2147483647]}}
11-
clang_analyzer_dump(b); // This should be either 4 or 10. expected-warning{{4}} expected-warning{{10}}
10+
clang_analyzer_value(a);
11+
// expected-warning@-1 {{[-2147483648, 10]}}
12+
// expected-warning@-2 {{[11, 2147483647]}}
13+
14+
clang_analyzer_dump(b); // expected-warning{{4}} expected-warning{{10}}
15+
1216
if (a > 20) {
13-
clang_analyzer_dump(b + 100); // expecting 104 expected-warning{{104}}
17+
clang_analyzer_dump(b + 100); // expected-warning {{104}}
1418
return 2;
1519
}
1620
if (a > 10) {
17-
clang_analyzer_dump(b + 200); // expecting 204 expected-warning{{204}}
21+
clang_analyzer_dump(b + 200); // expected-warning {{204}}
1822
return 1;
1923
}
20-
clang_analyzer_dump(b + 300); // expecting 310 expected-warning{{310}}
24+
clang_analyzer_dump(b + 300); // expected-warning {{310}}
2125
return 0;
2226
}
2327

2428
// From: https://github.com/llvm/llvm-project/pull/116462#issuecomment-2517853226
2529
int ternary_in_assume(int a, int b) {
2630
// FIXME notes
2731
// Currently, if this test is run without the core.builtin.Builtin checker, the above function with the __builtin_assume behaves identically to the following test
28-
// i.e. calls to `clang_analyzer_dump` result in "extraneous" prints of the SVal(s) `reg_$2<int > b ...`
32+
// i.e. calls to `clang_analyzer_dump` result in "extraneous" prints of the SVal(s) `reg<int b> ...`
2933
// as opposed to 4 or 10
3034
// which likely implies the Program State(s) did not get narrowed.
3135
// A new checker is likely needed to be implemented to properly handle the expressions within `[[assume]]` to eliminate the states where `b` is not narrowed.
3236

3337
[[assume(a > 10 ? b == 4 : b == 10)]];
34-
clang_analyzer_value(a); // we should have 2 dumps here. expected-warning{{[-2147483648, 10]}} expected-warning{{[11, 2147483647]}}
35-
clang_analyzer_dump(b); // This should be either 4 or 10. expected-warning{{4}} expected-warning{{10}} FIXME: expected-warning{{reg_$2<int b>}}
38+
clang_analyzer_value(a);
39+
// expected-warning@-1 {{[-2147483648, 10]}}
40+
// expected-warning@-2 {{[11, 2147483647]}}
41+
42+
clang_analyzer_dump(b); // expected-warning {{4}} expected-warning {{10}}
43+
// expected-warning-re@-1 {{reg_${{[0-9]+}}<int b>}} FIXME: We shouldn't have this dump.
44+
3645
if (a > 20) {
37-
clang_analyzer_dump(b + 100); // expecting 104 expected-warning{{104}} FIXME: expected-warning{{(reg_$2<int b>) + 100}}
46+
clang_analyzer_dump(b + 100); // expected-warning {{104}}
47+
// expected-warning-re@-1 {{(reg_${{[0-9]+}}<int b>) + 100}} FIXME: We shouldn't have this dump.
3848
return 2;
3949
}
4050
if (a > 10) {
41-
clang_analyzer_dump(b + 200); // expecting 204 expected-warning{{204}} FIXME: expected-warning{{(reg_$2<int b>) + 200}}
51+
clang_analyzer_dump(b + 200); // expected-warning {{204}}
52+
// expected-warning-re@-1 {{(reg_${{[0-9]+}}<int b>) + 200}} FIXME: We shouldn't have this dump.
4253
return 1;
4354
}
44-
clang_analyzer_dump(b + 300); // expecting 310 expected-warning{{310}} FIXME: expected-warning{{(reg_$2<int b>) + 300}}
55+
clang_analyzer_dump(b + 300); // expected-warning {{310}}
56+
// expected-warning-re@-1 {{(reg_${{[0-9]+}}<int b>) + 300}} FIXME: We shouldn't have this dump.
4557
return 0;
4658
}

0 commit comments

Comments
 (0)