Clang Project

clang_source_code/test/CodeGenCXX/cfi-blacklist.cpp
1// RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOBL %s
2
3// Check that blacklisting cfi and cfi-vcall work correctly
4// RUN: echo "[cfi-vcall]" > %t.vcall.txt
5// RUN: echo "type:std::*" >> %t.vcall.txt
6// RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -fsanitize-blacklist=%t.vcall.txt -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOSTD %s
7//
8// RUN: echo "[cfi]" > %t.cfi.txt
9// RUN: echo "type:std::*" >> %t.cfi.txt
10// RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -fsanitize-blacklist=%t.cfi.txt -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOSTD %s
11
12// Check that blacklisting non-vcall modes does not affect vcalls
13// RUN: echo "[cfi-icall|cfi-nvcall|cfi-cast-strict|cfi-derived-cast|cfi-unrelated-cast]" > %t.other.txt
14// RUN: echo "type:std::*" >> %t.other.txt
15// RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -fsanitize-blacklist=%t.other.txt -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOBL %s
16
17struct S1 {
18  virtual void f();
19};
20
21namespace std {
22
23struct S2 {
24  virtual void f();
25};
26
27}
28
29// CHECK: define{{.*}}s1f
30// NOBL: llvm.type.test
31// NOSTD: llvm.type.test
32void s1f(S1 *s1) {
33  s1->f();
34}
35
36// CHECK: define{{.*}}s2f
37// NOBL: llvm.type.test
38// NOSTD-NOT: llvm.type.test
39void s2f(std::S2 *s2) {
40  s2->f();
41}
42