diff options
author | Thomas Lively <tlively@google.com> | 2019-05-29 18:31:50 +0000 |
---|---|---|
committer | Thomas Lively <tlively@google.com> | 2019-05-29 18:31:50 +0000 |
commit | 5458cd4027f534a9c02ade8fadb66701c47366be (patch) | |
tree | 19ab5abf7257b878c5f1815b37d4b458ac4f2340 /clang/test | |
parent | dea605e0907804fd63365ac0273e8a39781fe25d (diff) | |
download | bcm5719-llvm-5458cd4027f534a9c02ade8fadb66701c47366be.tar.gz bcm5719-llvm-5458cd4027f534a9c02ade8fadb66701c47366be.zip |
[WebAssembly] Support VPtr sanitizer for Emscripten
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
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/CodeGenCXX/wasm-sanitize-vptr.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/wasm-sanitize-vptr.cpp b/clang/test/CodeGenCXX/wasm-sanitize-vptr.cpp new file mode 100644 index 00000000000..2a9055aea1e --- /dev/null +++ b/clang/test/CodeGenCXX/wasm-sanitize-vptr.cpp @@ -0,0 +1,20 @@ +// 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); +} |