1 // RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - -O0 %s | FileCheck %s -check-prefix=CHECK-O0
2 // RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - -O0 \
3 // RUN: -fsanitize=address -fsanitize-address-use-after-scope %s | \
4 // RUN: FileCheck %s -check-prefix=CHECK-ASAN-USE-AFTER-SCOPE
5
6 extern int bar(char *A, int n);
7
8 // CHECK-O0-NOT: @llvm.lifetime.start
foo(int n)9 int foo(int n) {
10 if (n) {
11 // CHECK-ASAN-USE-AFTER-SCOPE: @llvm.lifetime.start(i64 10, i8* {{.*}})
12 char A[10];
13 return bar(A, 1);
14 // CHECK-ASAN-USE-AFTER-SCOPE: @llvm.lifetime.end(i64 10, i8* {{.*}})
15 } else {
16 // CHECK-ASAN-USE-AFTER-SCOPE: @llvm.lifetime.start(i64 20, i8* {{.*}})
17 char A[20];
18 return bar(A, 2);
19 // CHECK-ASAN-USE-AFTER-SCOPE: @llvm.lifetime.end(i64 20, i8* {{.*}})
20 }
21 }
22