1*1c0af8dcSgbMattN // RUN: %clang_tysan %s -o %t && %run %t 10 >%t.out.0 2>&1 2*1c0af8dcSgbMattN // RUN: FileCheck --check-prefixes=CHECK,CHECK-BOTH %s < %t.out.0 3*1c0af8dcSgbMattN // RUN: echo "fun:typeViolationignored" > %tmp 4*1c0af8dcSgbMattN // RUN: echo "src:*ignorelist.h" > %tmp 5*1c0af8dcSgbMattN // RUN: %clang_tysan -fsanitize-ignorelist=%tmp %s -o %t && %run %t 10 >%t.out 2>&1 6*1c0af8dcSgbMattN // RUN: FileCheck --check-prefixes=CHECK-IGNORELIST,CHECK-BOTH %s < %t.out 7*1c0af8dcSgbMattN 8*1c0af8dcSgbMattN #include "ignorelist.h" 9*1c0af8dcSgbMattN #include <stdio.h> 10*1c0af8dcSgbMattN #include <stdlib.h> 11*1c0af8dcSgbMattN 12*1c0af8dcSgbMattN void typeViolationIgnored(float *fPtr) { printf("As int: %d\n", *(int *)fPtr); } 13*1c0af8dcSgbMattN 14*1c0af8dcSgbMattN void typeViolation(int *fPtr) { printf("As float: %f\n", *(float *)fPtr); } 15*1c0af8dcSgbMattN 16*1c0af8dcSgbMattN int main() { 17*1c0af8dcSgbMattN float *f = (float *)malloc(sizeof(float)); 18*1c0af8dcSgbMattN *f = 413.0f; 19*1c0af8dcSgbMattN typeViolationIgnored(f); 20*1c0af8dcSgbMattN // CHECK: TypeSanitizer: type-aliasing-violation on address 0x{{.*}} 21*1c0af8dcSgbMattN // CHECK-NEXT: READ of size 4 at 0x{{.*}} with type int accesses an existing object of type float 22*1c0af8dcSgbMattN // CHECK-IGNORELIST-NOT: TypeSanitizer: type-aliasing-violation on address 0x{{.*}} 23*1c0af8dcSgbMattN 24*1c0af8dcSgbMattN int *i = (int *)malloc(sizeof(int)); 25*1c0af8dcSgbMattN *i = 612; 26*1c0af8dcSgbMattN typeViolation(i); 27*1c0af8dcSgbMattN // CHECK-BOTH: TypeSanitizer: type-aliasing-violation on address 0x{{.*}} 28*1c0af8dcSgbMattN // CHECK-BOTH: READ of size 4 at 0x{{.*}} with type float accesses an existing object of type int 29*1c0af8dcSgbMattN 30*1c0af8dcSgbMattN typeViolationMultiFile((void *)i); 31*1c0af8dcSgbMattN // CHECK: TypeSanitizer: type-aliasing-violation on address 0x{{.*}} 32*1c0af8dcSgbMattN // CHECK-IGNORELIST-NOT: TypeSanitizer: type-aliasing-violation on address 0x{{.*}} 33*1c0af8dcSgbMattN 34*1c0af8dcSgbMattN return 0; 35*1c0af8dcSgbMattN } 36