| 1 |
// Test AllocToken respects ignorelist for functions and files. |
| 2 |
// |
| 3 |
// RUN: %clang_cc1 -fsanitize=alloc-token -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-ALLOW |
| 4 |
// |
| 5 |
// RUN: echo "fun:excluded_by_all" > %t.func.ignorelist |
| 6 |
// RUN: %clang_cc1 -fsanitize=alloc-token -fsanitize-ignorelist=%t.func.ignorelist -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-FUN |
| 7 |
// |
| 8 |
// RUN: echo "src:%s" | sed -e 's/\\/\\\\/g' > %t.file.ignorelist |
| 9 |
// RUN: %clang_cc1 -fsanitize=alloc-token -fsanitize-ignorelist=%t.file.ignorelist -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-SRC |
| 10 |
|
| 11 |
extern void* malloc(unsigned long size); |
| 12 |
|
| 13 |
// CHECK-LABEL: define{{.*}} @excluded_by_all( |
| 14 |
void* excluded_by_all(unsigned long size) { |
| 15 |
// CHECK-ALLOW: call ptr @__alloc_token_malloc( |
| 16 |
// CHECK-FUN: call ptr @malloc( |
| 17 |
// CHECK-SRC: call ptr @malloc( |
| 18 |
return malloc(size); |
| 19 |
} |
| 20 |
|
| 21 |
// CHECK-LABEL: define{{.*}} @excluded_by_src( |
| 22 |
void* excluded_by_src(unsigned long size) { |
| 23 |
// CHECK-ALLOW: call ptr @__alloc_token_malloc( |
| 24 |
// CHECK-FUN: call ptr @__alloc_token_malloc( |
| 25 |
// CHECK-SRC: call ptr @malloc( |
| 26 |
return malloc(size); |
| 27 |
} |