1 // RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - %s | FileCheck %s 2 3 // Test blacklist functionality. 4 // RUN: echo "src:%s=init" > %t-file.blacklist 5 // RUN: echo "type:PODWithCtorAndDtor=init" > %t-type.blacklist 6 // RUN: echo "type:NS::PODWithCtor=init" >> %t-type.blacklist 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 9 // REQUIRES: shell 10 11 struct PODStruct { 12 int x; 13 }; 14 PODStruct s1; 15 16 struct PODWithDtor { ~PODWithDtorPODWithDtor17 ~PODWithDtor() { } 18 int x; 19 }; 20 PODWithDtor s2; 21 22 struct PODWithCtorAndDtor { PODWithCtorAndDtorPODWithCtorAndDtor23 PODWithCtorAndDtor() { } ~PODWithCtorAndDtorPODWithCtorAndDtor24 ~PODWithCtorAndDtor() { } 25 int x; 26 }; 27 PODWithCtorAndDtor s3; 28 29 namespace NS { 30 class PODWithCtor { 31 public: PODWithCtor()32 PODWithCtor() {} 33 }; 34 35 const volatile PODWithCtor array[5][5]; 36 } 37 38 // Check that ASan init-order checking ignores structs with trivial default 39 // constructor. 40 // CHECK: !llvm.asan.globals = !{![[GLOB_1:[0-9]+]], ![[GLOB_2:[0-9]+]], ![[GLOB_3:[0-9]]], ![[GLOB_4:[0-9]]]} 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} 45 46 // BLACKLIST: !llvm.asan.globals = !{![[GLOB_1:[0-9]+]], ![[GLOB_2:[0-9]+]], ![[GLOB_3:[0-9]]], ![[GLOB_4:[0-9]]]} 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} 51