summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/wasm-sanitize-vptr.cpp
blob: 2a9055aea1ef81aedcf1cbeb192ff2ba49ce2177 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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);
}
OpenPOWER on IntegriCloud