1 // Verify ubsan vptr does not check down-casts on ignorelisted types.
2 // RUN: echo "type:_ZTI3Foo" > %t-type.ignorelist
3 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=vptr -fsanitize-recover=vptr -emit-llvm %s -o - | FileCheck %s --check-prefix=DEFAULT
4 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=vptr -fsanitize-recover=vptr -fsanitize-ignorelist=%t-type.ignorelist -emit-llvm %s -o - | FileCheck %s --check-prefix=TYPE
5
6 class Bar {
7 public:
~Bar()8 virtual ~Bar() {}
9 };
10 class Foo : public Bar {};
11
12 Bar bar;
13
14 // DEFAULT: @_Z7checkmev
15 // TYPE: @_Z7checkmev
checkme()16 void checkme() {
17 // DEFAULT: call void @__ubsan_handle_dynamic_type_cache_miss({{.*}} (ptr @bar to
18 // TYPE-NOT: @__ubsan_handle_dynamic_type_cache_miss
19 Foo* foo = static_cast<Foo*>(&bar); // down-casting
20 // DEFAULT: ret void
21 // TYPE: ret void
22 return;
23 }
24