Debian Codegraph @

clang/test/AST/ByteCode/codegen-constexpr-unknown.cpp

raw
1 // RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -fcxx-exceptions -o - %s | FileCheck %s
2 // RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -fcxx-exceptions -o - %s -fexperimental-new-constant-interpreter | FileCheck %s
3
4
5 /// In the if expression below, the read from s.i should fail.
6 /// If it doesn't, and we actually read the value 0, the call to
7 /// func() will always occur, resuliting in a runtime failure.
8
9 struct S {
10 mutable int i = 0;
11 };
12
13 void func() {
14 __builtin_abort();
15 };
16
17 void setI(const S &s) {
18 s.i = 12;
19 }
20
21 int main() {
22 const S s;
23
24 setI(s);
25
26 if (s.i == 0)
27 func();
28
29 return 0;
30 }
31
32 // CHECK: define dso_local noundef i32 @main()
33 // CHECK: br
34 // CHECK: if.then
35 // CHECK: if.end
36 // CHECK: ret i32 0
37
38
39 /// Similarly, here we revisit the BindingDecl.
40 struct F { int x; };
41 int main2() {
42 const F const s{99};
43 const auto& [r1] = s;
44 if (&r1 != &s.x)
45 __builtin_abort();
46 return 0;
47 }
48 // CHECK: define dso_local noundef i32 @_Z5main2v()
49 // CHECK: br
50 // CHECK: if.then
51 // CHECK: if.end
52 // CHECK: ret i32 0
53
54 /// The comparison here should work and return 0.
55 class X {
56 public:
57 X();
58 X(const X&);
59 X(const volatile X &);
60 ~X();
61 };
62 extern X OuterX;
63 X test24() {
64 X x;
65 if (&x == &OuterX)
66 throw 0;
67 return x;
68 }
69
70 // CHECK: define dso_local void @_Z6test24v
71 // CHECK-NOT: lpad
72 // CHECK-NOT: eh.resume