blob: 91a4b1bf5d81b7cf4aec24cf78764fdbb93f0958 [file] [log] [blame]
Chad Rosier78d85b12013-01-29 23:31:22 +00001// RUN: %clang -target x86_64-linux-gnu -fcatch-undefined-behavior %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-TRAP
2// RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined-trap -fsanitize-undefined-trap-on-error %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-TRAP
3// RUN: %clang -target x86_64-linux-gnu -fsanitize-undefined-trap-on-error -fsanitize=undefined-trap %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-TRAP
4// CHECK-UNDEFINED-TRAP: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|shift|unreachable|return|vla-bound|alignment|null|object-size|float-cast-overflow|bounds|enum|bool),?){14}"}}
5// CHECK-UNDEFINED-TRAP: "-fsanitize-undefined-trap-on-error"
6
Richard Smithc4dabad2012-11-05 22:04:41 +00007// RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED
Richard Smith463b48b2012-12-13 07:11:50 +00008// CHECK-UNDEFINED: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|shift|unreachable|return|vla-bound|alignment|null|vptr|object-size|float-cast-overflow|bounds|enum|bool),?){15}"}}
Richard Smithc4dabad2012-11-05 22:04:41 +00009
Will Dietzb8540362012-11-27 15:01:55 +000010// RUN: %clang -target x86_64-linux-gnu -fsanitize=integer %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-INTEGER
11// CHECK-INTEGER: "-fsanitize={{((signed-integer-overflow|unsigned-integer-overflow|integer-divide-by-zero|shift),?){4}"}}
12
Richard Smith463b48b2012-12-13 07:11:50 +000013// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread,undefined -fno-thread-sanitizer -fno-sanitize=float-cast-overflow,vptr,bool,enum %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PARTIAL-UNDEFINED
Will Dietzb8540362012-11-27 15:01:55 +000014// CHECK-PARTIAL-UNDEFINED: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|shift|unreachable|return|vla-bound|alignment|null|object-size|bounds),?){11}"}}
Richard Smithc4dabad2012-11-05 22:04:41 +000015
Alexey Samsonov4d1a6e42012-11-29 22:36:21 +000016// RUN: %clang -target x86_64-linux-gnu -fsanitize=address-full %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-FULL
17// CHECK-ASAN-FULL: "-fsanitize={{((address|init-order|use-after-return|use-after-scope),?){4}"}}
18
Alexey Samsonov7d0d85f2013-03-19 10:48:37 +000019// RUN: %clang -target x86_64-linux-gnu -fno-sanitize=init-order -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-IMPLIED-INIT-ORDER
Alexey Samsonov7ac415b2013-03-14 12:13:27 +000020// CHECK-ASAN-IMPLIED-INIT-ORDER: "-fsanitize={{((address|init-order),?){2}"}}
21
22// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fno-sanitize=init-order %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-NO-IMPLIED-INIT-ORDER
23// CHECK-ASAN-NO-IMPLIED-INIT-ORDER-NOT: init-order
24
Chad Rosier78d85b12013-01-29 23:31:22 +000025// RUN: %clang -target x86_64-linux-gnu -fcatch-undefined-behavior -fno-sanitize-undefined-trap-on-error %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-NO-TRAP-ERROR
26// CHECK-UNDEFINED-NO-TRAP-ERROR: '-fcatch-undefined-behavior' not allowed with '-fno-sanitize-undefined-trap-on-error'
27
28// RUN: %clang -target x86_64-linux-gnu -fsanitize=vptr -fcatch-undefined-behavior %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-VPTR-UNDEF-ERROR
29// CHECK-VPTR-UNDEF-ERROR: '-fsanitize=vptr' not allowed with '-fcatch-undefined-behavior'
30
31// RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined -fsanitize-undefined-trap-on-error %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-TRAP-ON-ERROR-UNDEF
32// CHECK-UNDEFINED-TRAP-ON-ERROR-UNDEF: '-fsanitize=undefined' not allowed with '-fsanitize-undefined-trap-on-error'
33
34// RUN: %clang -target x86_64-linux-gnu -fsanitize=vptr -fsanitize-undefined-trap-on-error %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-TRAP-ON-ERROR-VPTR
35// CHECK-UNDEFINED-TRAP-ON-ERROR-VPTR: '-fsanitize=vptr' not allowed with '-fsanitize-undefined-trap-on-error'
36
Joey Gouly4247d9c2012-12-01 13:07:22 +000037// RUN: %clang -target x86_64-linux-gnu -fsanitize=vptr -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-VPTR-NO-RTTI
38// RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-VPTR-NO-RTTI
Richard Smith04fd3822012-11-06 01:12:02 +000039// CHECK-VPTR-NO-RTTI: '-fsanitize=vptr' not allowed with '-fno-rtti'
Richard Smithc4dabad2012-11-05 22:04:41 +000040
Joey Gouly4247d9c2012-12-01 13:07:22 +000041// RUN: %clang -target x86_64-linux-gnu -fsanitize=address,thread -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANA-SANT
Richard Smithc4dabad2012-11-05 22:04:41 +000042// CHECK-SANA-SANT: '-fsanitize=address' not allowed with '-fsanitize=thread'
43
Evgeniy Stepanov34ef11b2012-12-24 08:42:34 +000044// RUN: %clang -target x86_64-linux-gnu -fsanitize=address,memory -pie -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANA-SANM
Evgeniy Stepanov99469f72012-12-05 13:37:12 +000045// CHECK-SANA-SANM: '-fsanitize=address' not allowed with '-fsanitize=memory'
46
Evgeniy Stepanov34ef11b2012-12-24 08:42:34 +000047// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread,memory -pie -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANT-SANM
Evgeniy Stepanov99469f72012-12-05 13:37:12 +000048// CHECK-SANT-SANM: '-fsanitize=thread' not allowed with '-fsanitize=memory'
49
Evgeniy Stepanov34ef11b2012-12-24 08:42:34 +000050// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory,thread -pie -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANM-SANT
Evgeniy Stepanov99469f72012-12-05 13:37:12 +000051// CHECK-SANM-SANT: '-fsanitize=thread' not allowed with '-fsanitize=memory'
52
Joey Gouly4247d9c2012-12-01 13:07:22 +000053// RUN: %clang -target x86_64-linux-gnu -faddress-sanitizer -fthread-sanitizer -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-TSAN
Richard Smith04fd3822012-11-06 01:12:02 +000054// CHECK-ASAN-TSAN: '-faddress-sanitizer' not allowed with '-fthread-sanitizer'
55
Joey Gouly4247d9c2012-12-01 13:07:22 +000056// RUN: %clang -target x86_64-linux-gnu -fsanitize=init-order %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ONLY-EXTRA-ASAN
Alexey Samsonov3e335c12013-01-28 07:20:44 +000057// CHECK-ONLY-EXTRA-ASAN: '-fsanitize=init-order' is ignored in absence of '-fsanitize=address'
58
59// RUN: %clang -target x86_64-linux-gnu -Wno-unused-sanitize-argument -fsanitize=init-order %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-WNO-UNUSED-SANITIZE-ARGUMENT
60// CHECK-WNO-UNUSED-SANITIZE-ARGUMENT-NOT: '-fsanitize=init-order' is ignored in absence of '-fsanitize=address'
61
62// RUN: %clang -target x86_64-linux-gnu -fsanitize=address,init-order -fno-sanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NOWARN-ONLY-EXTRA-ASAN
63// CHECK-NOWARN-ONLY-EXTRA-ASAN-NOT: is ignored in absence of '-fsanitize=address'
Alexey Samsonov4d1a6e42012-11-29 22:36:21 +000064
Evgeniy Stepanov34ef11b2012-12-24 08:42:34 +000065// RUN: %clang -target x86_64-linux-gnu -fsanitize-memory-track-origins -pie %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ONLY-TRACK-ORIGINS
66// CHECK-ONLY-TRACK-ORIGINS: warning: argument unused during compilation: '-fsanitize-memory-track-origins'
67
Alexey Samsonova40548c2013-01-16 11:34:36 +000068// RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-EXTRA-TRACK-ORIGINS
69// CHECK-NO-EXTRA-TRACK-ORIGINS-NOT: "-fsanitize-memory-track-origins"
70
Alexey Samsonov4bdc6042013-01-20 13:12:12 +000071// RUN: %clang -target x86_64-linux-gnu -fsanitize-address-zero-base-shadow -pie %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ONLY-ASAN-ZERO-BASE-SHADOW
72// CHECK-ONLY-ASAN-ZERO-BASE-SHADOW: warning: argument unused during compilation: '-fsanitize-address-zero-base-shadow'
73
Joey Gouly4247d9c2012-12-01 13:07:22 +000074// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize=alignment -fsanitize=vptr -fno-sanitize=vptr %s -### 2>&1
Richard Smith05650372012-12-01 01:02:45 +000075// OK
Alexey Samsonov3325b162012-11-28 17:34:24 +000076
Evgeniy Stepanov34ef11b2012-12-24 08:42:34 +000077// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory -pie %s -### 2>&1
78// OK
79
80// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory -fsanitize-memory-track-origins -pie %s -### 2>&1
81// OK
82
Joey Gouly4247d9c2012-12-01 13:07:22 +000083// RUN: %clang -target x86_64-linux-gnu -fsanitize=vptr -fno-sanitize=vptr -fsanitize=undefined,address %s -### 2>&1
Richard Smith05650372012-12-01 01:02:45 +000084// OK
Alexey Samsonov3325b162012-11-28 17:34:24 +000085
Alexey Samsonov4bdc6042013-01-20 13:12:12 +000086// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-address-zero-base-shadow -pie %s -### 2>&1
87// OK
88
Joey Gouly4247d9c2012-12-01 13:07:22 +000089// RUN: %clang -target x86_64-linux-gnu -fcatch-undefined-behavior -fthread-sanitizer -fno-thread-sanitizer -faddress-sanitizer -fno-address-sanitizer -fbounds-checking -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-DEPRECATED
Chad Rosier78d85b12013-01-29 23:31:22 +000090// CHECK-DEPRECATED: argument '-fcatch-undefined-behavior' is deprecated, use '-fsanitize=undefined-trap -fsanitize-undefined-trap-on-error' instead
Richard Smith04fd3822012-11-06 01:12:02 +000091// CHECK-DEPRECATED: argument '-fthread-sanitizer' is deprecated, use '-fsanitize=thread' instead
92// CHECK-DEPRECATED: argument '-fno-thread-sanitizer' is deprecated, use '-fno-sanitize=thread' instead
93// CHECK-DEPRECATED: argument '-faddress-sanitizer' is deprecated, use '-fsanitize=address' instead
94// CHECK-DEPRECATED: argument '-fno-address-sanitizer' is deprecated, use '-fno-sanitize=address' instead
Joey Gouly85489082012-11-23 10:39:49 +000095// CHECK-DEPRECATED: argument '-fbounds-checking' is deprecated, use '-fsanitize=bounds' instead
Evgeniy Stepanov99469f72012-12-05 13:37:12 +000096
97// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-NO-PIE
Peter Collingbourne52ca70d2013-04-09 04:35:11 +000098// CHECK-TSAN-NO-PIE: "-mrelocation-model" "pic" "-pic-level" "2" "-pie-level" "2"
99// CHECK-TSAN-NO-PIE: "-pie"
Evgeniy Stepanov99469f72012-12-05 13:37:12 +0000100
101// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN-NO-PIE
Peter Collingbourne52ca70d2013-04-09 04:35:11 +0000102// CHECK-MSAN-NO-PIE: "-mrelocation-model" "pic" "-pic-level" "2" "-pie-level" "2"
103// CHECK-MSAN-NO-PIE: "-pie"
Evgeniy Stepanov99469f72012-12-05 13:37:12 +0000104
Alexey Samsonov4bdc6042013-01-20 13:12:12 +0000105// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-address-zero-base-shadow %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-ZERO-BASE-SHADOW-NO-PIE
Peter Collingbourne52ca70d2013-04-09 04:35:11 +0000106// CHECK-ASAN-ZERO-BASE-SHADOW-NO-PIE: "-mrelocation-model" "pic" "-pic-level" "2" "-pie-level" "2"
107// CHECK-ASAN-ZERO-BASE-SHADOW-NO-PIE: "-pie"
Alexey Samsonov4bdc6042013-01-20 13:12:12 +0000108
109// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-address-zero-base-shadow -fno-sanitize-address-zero-base-shadow %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-ZERO-BASE-SHADOW-CANCEL
Peter Collingbourne52ca70d2013-04-09 04:35:11 +0000110// CHECK-ASAN-ZERO-BASE-SHADOW-CANCEL-NOT: "-mrelocation-model" "pic" "-pic-level" "2" "-pie-level" "2"
111// CHECK-ASAN-ZERO-BASE-SHADOW-CANCEL-NOT: "-pie"
Alexey Samsonov4bdc6042013-01-20 13:12:12 +0000112
Evgeniy Stepanov99469f72012-12-05 13:37:12 +0000113// RUN: %clang -target arm-linux-androideabi -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ANDROID-ASAN-NO-PIE
Peter Collingbourne52ca70d2013-04-09 04:35:11 +0000114// CHECK-ANDROID-ASAN-NO-PIE: "-mrelocation-model" "pic" "-pic-level" "2" "-pie-level" "2"
115// CHECK-ANDROID-ASAN-NO-PIE: "-pie"
Will Dietz2d382d12012-12-30 20:53:28 +0000116
117// RUN: %clang -target x86_64-linux-gnu %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER
118// RUN: %clang -target x86_64-linux-gnu %s -fsanitize-recover -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER
119// RUN: %clang -target x86_64-linux-gnu %s -fno-sanitize-recover -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-RECOVER
120// RUN: %clang -target x86_64-linux-gnu %s -fno-sanitize-recover -fsanitize-recover -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER
121// RUN: %clang -target x86_64-linux-gnu %s -fsanitize-recover -fno-sanitize-recover -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-RECOVER
122// CHECK-RECOVER-NOT: sanitize-recover
123// CHECK-NO-RECOVER: "-fno-sanitize-recover"