[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CodeGen / noundef-analysis.cpp
blob21184437b796d91b044390c10037b1bf86686e1f
1 // RUN: %clang_cc1 -triple arm64-darwin -enable-noundef-analysis -emit-llvm -o - %s | FileCheck %s -check-prefix ENABLED
2 // RUN: %clang_cc1 -triple arm64-darwin -no-enable-noundef-analysis -emit-llvm -o - %s | FileCheck %s -check-prefix DISABLED
4 union u1 {
5 int val;
6 };
8 struct s1 {
9 int val;
12 int indirect_callee_int(int a) { return a; }
13 union u1 indirect_callee_union(union u1 a) {
14 return a;
17 static int sink;
19 static void examineValue(int x) { sink = x; }
21 // ENABLED-LABEL: @main(
22 // ENABLED: [[CALL:%.*]] = call noundef {{.*}}i32 @_Z19indirect_callee_inti(i32 noundef {{.*}}0)
23 // ENABLED: [[CALL1:%.*]] = call i32 @_Z21indirect_callee_union2u1(i64 {{.*}})
24 // ENABLED: [[CALL2:%.*]] = call noalias noundef nonnull ptr @_Znwm(i64 noundef 4) #[[ATTR4:[0-9]+]]
25 // ENABLED: call void @_ZL12examineValuei(i32 noundef {{.*}})
26 // DISABLED-LABEL: @main(
27 // DISABLED: [[CALL:%.*]] = call {{.*}}i32 @_Z19indirect_callee_inti(i32 {{.*}}0)
28 // DISABLED: [[CALL1:%.*]] = call i32 @_Z21indirect_callee_union2u1(i64 {{.*}})
29 // DISABLED: [[CALL2:%.*]] = call noalias nonnull ptr @_Znwm(i64 4) #[[ATTR4:[0-9]+]]
30 // DISABLED: call void @_ZL12examineValuei(i32 {{.*}})
31 int main() {
32 indirect_callee_int(0);
33 indirect_callee_union((union u1){0});
35 auto s = new s1;
36 examineValue(s->val);
38 return 0;