1 // Frontend rejects invalid option
2 // RUN: not %clang_cc1 -fsanitize=address \
3 // RUN:   -fsanitize-address-destructor=bad_arg -emit-llvm -o - \
4 // RUN:   -triple x86_64-apple-macosx10.15 %s 2>&1 | \
5 // RUN:   FileCheck %s --check-prefixes=CHECK-BAD-ARG
6 // CHECK-BAD-ARG: invalid value 'bad_arg' in '-fsanitize-address-destructor=bad_arg'
7 
8 // Default is global dtor
9 // RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-apple-macosx10.15 \
10 // RUN:   -fno-legacy-pass-manager %s \
11 // RUN:   | FileCheck %s --check-prefixes=CHECK-GLOBAL-DTOR
12 //
13 // RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-apple-macosx10.15 \
14 // RUN:   -flegacy-pass-manager %s \
15 // RUN:   | FileCheck %s --check-prefixes=CHECK-GLOBAL-DTOR
16 
17 // Explictly ask for global dtor
18 // RUN: %clang_cc1 -fsanitize=address \
19 // RUN:   -fsanitize-address-destructor=global -emit-llvm -o - \
20 // RUN:   -triple x86_64-apple-macosx10.15 -fno-legacy-pass-manager %s | \
21 // RUN:   FileCheck %s --check-prefixes=CHECK-GLOBAL-DTOR
22 //
23 // RUN: %clang_cc1 -fsanitize=address \
24 // RUN:   -fsanitize-address-destructor=global -emit-llvm -o - \
25 // RUN:   -triple x86_64-apple-macosx10.15 -flegacy-pass-manager %s | \
26 // RUN:   FileCheck %s --check-prefixes=CHECK-GLOBAL-DTOR
27 
28 // CHECK-GLOBAL-DTOR: llvm.global_dtor{{.+}}asan.module_dtor
29 // CHECK-GLOBAL-DTOR: define internal void @asan.module_dtor
30 
31 // Explictly ask for no dtors
32 // RUN: %clang_cc1 -fsanitize=address \
33 // RUN:   -fsanitize-address-destructor=none -emit-llvm -o - \
34 // RUN:   -triple x86_64-apple-macosx10.15 -fno-legacy-pass-manager %s | \
35 // RUN:   FileCheck %s --check-prefixes=CHECK-NONE-DTOR
36 //
37 // RUN: %clang_cc1 -fsanitize=address \
38 // RUN:   -fsanitize-address-destructor=none -emit-llvm -o - \
39 // RUN:   -triple x86_64-apple-macosx10.15 -flegacy-pass-manager %s | \
40 // RUN:   FileCheck %s --check-prefixes=CHECK-NONE-DTOR
41 
42 int global;
43 
44 int main() {
45   return global;
46 }
47 
48 // CHECK-NONE-DTOR-NOT: llvm.global_dtor{{.+}}asan.module_dtor
49 // CHECK-NONE-DTOR-NOT: define internal void @asan.module_dtor
50