brintos

brintos / llvm-project-archived public Read only

0
0
Text · 653 B · 6142ca5 Raw
30 lines · cpp
1// RUN: %clang_cc1 -flto -flto-unit -emit-llvm -o - -triple=x86_64-pc-win32 %s -fsanitize=cfi-derived-cast -fsanitize-trap=cfi-derived-cast | FileCheck %s2 3struct foo {4  virtual ~foo() {}5  virtual void f() = 0;6};7 8template <typename T>9struct bar : virtual public foo {10  void f() {11    // CHECK: define{{.*}}@"?f@?$bar@Ubaz@@@@UEAAXXZ"12    // Load "this", vbtable, vbase offset and vtable.13    // CHECK: load14    // CHECK: load15    // CHECK: load16    // CHECK: load17    // CHECK: @llvm.type.test{{.*}}!"?AUfoo@@"18    static_cast<T&>(*this);19  }20};21 22struct baz : public bar<baz> {23  virtual ~baz() {}24};25 26int main() {27  baz *z = new baz;28  z->f();29}30