mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-27 11:46:07 +00:00

Summary: After https://github.com/emscripten-core/emscripten/pull/8651, Emscripten supports the full UBSan runtime. This includes the VPtr sanitizer. This diff allows clang to generate code that uses the VPtr sanitizer for Emscripten. Patch by Guanzhong Chen Reviewers: tlively, aheejin Reviewed By: aheejin Subscribers: dschuff, sbc100, jgravelle-google, sunfish, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62559 llvm-svn: 362004
21 lines
480 B
C++
21 lines
480 B
C++
// RUN: %clang_cc1 -std=c++11 -fsanitize=vptr -emit-llvm %s -o - -triple wasm32-unknown-emscripten | FileCheck %s
|
|
|
|
struct S {
|
|
virtual ~S() {}
|
|
int a;
|
|
};
|
|
|
|
struct T : S {
|
|
int b;
|
|
};
|
|
|
|
// CHECK-LABEL: @_Z15bad_static_castv
|
|
void bad_static_cast() {
|
|
S s;
|
|
// CHECK: br i1 %[[NONNULL:.*]], label %[[CONT:.*]], label %[[MISS:.*]], !prof
|
|
// CHECK: [[MISS]]:
|
|
// CHECK: call void @__ubsan_handle_dynamic_type_cache_miss_abort
|
|
// CHECK: [[CONT]]:
|
|
T &r = static_cast<T &>(s);
|
|
}
|