blob: ee53f7b0771eb7b67514fa09fc2ddc90965d9724 [file] [log] [blame]
Alexey Samsonove595e1a2014-06-13 17:53:44 +00001// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - %s | FileCheck %s
Alexey Samsonovcb9efbe2013-04-05 07:47:28 +00002
Alexey Samsonovc054d982014-05-29 01:43:53 +00003// Test blacklist functionality.
Alexey Samsonovcfb97aa2014-11-20 01:27:19 +00004// RUN: echo "src:%s=init" > %t-file.blacklist
5// RUN: echo "type:PODWithCtorAndDtor=init" > %t-type.blacklist
Alexey Samsonova0ac3c22014-10-17 22:37:33 +00006// RUN: echo "type:NS::PODWithCtor=init" >> %t-type.blacklist
Alexey Samsonove595e1a2014-06-13 17:53:44 +00007// 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 Samsonovc054d982014-05-29 01:43:53 +00009// REQUIRES: shell
10
Alexey Samsonovcb9efbe2013-04-05 07:47:28 +000011struct PODStruct {
12 int x;
13};
14PODStruct s1;
15
16struct PODWithDtor {
17 ~PODWithDtor() { }
18 int x;
19};
20PODWithDtor s2;
21
22struct PODWithCtorAndDtor {
23 PODWithCtorAndDtor() { }
24 ~PODWithCtorAndDtor() { }
25 int x;
26};
27PODWithCtorAndDtor s3;
28
Alexey Samsonova0ac3c22014-10-17 22:37:33 +000029namespace NS {
30class PODWithCtor {
31public:
32 PODWithCtor() {}
33};
34
35const volatile PODWithCtor array[5][5];
36}
37
Alexey Samsonovcb9efbe2013-04-05 07:47:28 +000038// Check that ASan init-order checking ignores structs with trivial default
39// constructor.
Alexey Samsonova0ac3c22014-10-17 22:37:33 +000040// CHECK: !llvm.asan.globals = !{![[GLOB_1:[0-9]+]], ![[GLOB_2:[0-9]+]], ![[GLOB_3:[0-9]]], ![[GLOB_4:[0-9]]]}
Duncan P. N. Exon Smithb3a66692014-12-15 19:10:08 +000041// 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 Samsonovc054d982014-05-29 01:43:53 +000045
Alexey Samsonova0ac3c22014-10-17 22:37:33 +000046// BLACKLIST: !llvm.asan.globals = !{![[GLOB_1:[0-9]+]], ![[GLOB_2:[0-9]+]], ![[GLOB_3:[0-9]]], ![[GLOB_4:[0-9]]]}
Duncan P. N. Exon Smithb3a66692014-12-15 19:10:08 +000047// 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}