Alexey Samsonov | e595e1a | 2014-06-13 17:53:44 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - %s | FileCheck %s |
Alexey Samsonov | cb9efbe | 2013-04-05 07:47:28 +0000 | [diff] [blame] | 2 | |
Alexey Samsonov | c054d98 | 2014-05-29 01:43:53 +0000 | [diff] [blame] | 3 | // Test blacklist functionality. |
Alexey Samsonov | cfb97aa | 2014-11-20 01:27:19 +0000 | [diff] [blame] | 4 | // RUN: echo "src:%s=init" > %t-file.blacklist |
| 5 | // RUN: echo "type:PODWithCtorAndDtor=init" > %t-type.blacklist |
Alexey Samsonov | a0ac3c2 | 2014-10-17 22:37:33 +0000 | [diff] [blame] | 6 | // RUN: echo "type:NS::PODWithCtor=init" >> %t-type.blacklist |
Alexey Samsonov | e595e1a | 2014-06-13 17:53:44 +0000 | [diff] [blame] | 7 | // RUN: %clang_cc1 -fsanitize=address -fsanitize-blacklist=%t-file.blacklist -emit-llvm -o - %s | FileCheck %s --check-prefix=BLACKLIST |
| 8 | // RUN: %clang_cc1 -fsanitize=address -fsanitize-blacklist=%t-type.blacklist -emit-llvm -o - %s | FileCheck %s --check-prefix=BLACKLIST |
Alexey Samsonov | c054d98 | 2014-05-29 01:43:53 +0000 | [diff] [blame] | 9 | // REQUIRES: shell |
| 10 | |
Alexey Samsonov | cb9efbe | 2013-04-05 07:47:28 +0000 | [diff] [blame] | 11 | struct PODStruct { |
| 12 | int x; |
| 13 | }; |
| 14 | PODStruct s1; |
| 15 | |
| 16 | struct PODWithDtor { |
| 17 | ~PODWithDtor() { } |
| 18 | int x; |
| 19 | }; |
| 20 | PODWithDtor s2; |
| 21 | |
| 22 | struct PODWithCtorAndDtor { |
| 23 | PODWithCtorAndDtor() { } |
| 24 | ~PODWithCtorAndDtor() { } |
| 25 | int x; |
| 26 | }; |
| 27 | PODWithCtorAndDtor s3; |
| 28 | |
Alexey Samsonov | a0ac3c2 | 2014-10-17 22:37:33 +0000 | [diff] [blame] | 29 | namespace NS { |
| 30 | class PODWithCtor { |
| 31 | public: |
| 32 | PODWithCtor() {} |
| 33 | }; |
| 34 | |
| 35 | const volatile PODWithCtor array[5][5]; |
| 36 | } |
| 37 | |
Alexey Samsonov | cb9efbe | 2013-04-05 07:47:28 +0000 | [diff] [blame] | 38 | // Check that ASan init-order checking ignores structs with trivial default |
| 39 | // constructor. |
Alexey Samsonov | a0ac3c2 | 2014-10-17 22:37:33 +0000 | [diff] [blame] | 40 | // CHECK: !llvm.asan.globals = !{![[GLOB_1:[0-9]+]], ![[GLOB_2:[0-9]+]], ![[GLOB_3:[0-9]]], ![[GLOB_4:[0-9]]]} |
Duncan P. N. Exon Smith | b3a6669 | 2014-12-15 19:10:08 +0000 | [diff] [blame] | 41 | // CHECK: ![[GLOB_1]] = !{%struct.PODStruct* {{.*}}, i1 false, i1 false} |
| 42 | // CHECK: ![[GLOB_2]] = !{%struct.PODWithDtor* {{.*}}, i1 false, i1 false} |
| 43 | // CHECK: ![[GLOB_3]] = !{%struct.PODWithCtorAndDtor* {{.*}}, i1 true, i1 false} |
| 44 | // CHECK: ![[GLOB_4]] = !{{{.*}}class.NS::PODWithCtor{{.*}}, i1 true, i1 false} |
Alexey Samsonov | c054d98 | 2014-05-29 01:43:53 +0000 | [diff] [blame] | 45 | |
Alexey Samsonov | a0ac3c2 | 2014-10-17 22:37:33 +0000 | [diff] [blame] | 46 | // BLACKLIST: !llvm.asan.globals = !{![[GLOB_1:[0-9]+]], ![[GLOB_2:[0-9]+]], ![[GLOB_3:[0-9]]], ![[GLOB_4:[0-9]]]} |
Duncan P. N. Exon Smith | b3a6669 | 2014-12-15 19:10:08 +0000 | [diff] [blame] | 47 | // BLACKLIST: ![[GLOB_1]] = !{%struct.PODStruct* {{.*}}, i1 false, i1 false} |
| 48 | // BLACKLIST: ![[GLOB_2]] = !{%struct.PODWithDtor* {{.*}}, i1 false, i1 false} |
| 49 | // BLACKLIST: ![[GLOB_3]] = !{%struct.PODWithCtorAndDtor* {{.*}}, i1 false, i1 false} |
| 50 | // BLACKLIST: ![[GLOB_4]] = !{{{.*}}class.NS::PODWithCtor{{.*}}, i1 false, i1 false} |