llvm-project/clang/test/CodeGenCXX/vtable-key-function-win-comdat.cpp
Daniil Kovalev 6bb63002fc
[PAC] Fix address discrimination for type info vtable pointers (#102199)
In #99726, `-fptrauth-type-info-vtable-pointer-discrimination` was
introduced, which is intended to enable type and address discrimination
for type_info vtable pointers. However, some codegen logic for actually
enabling address discrimination was missing. This patch addresses the
issue.

Fixes #101716
2024-10-18 08:58:26 +03:00

26 lines
823 B
C++

// RUN: %clang_cc1 %s -triple=x86_64-pc-windows-gnu -emit-llvm -o - | FileCheck %s
namespace std { class type_info; }
extern void use(const std::type_info &rtti);
struct Test1a {
Test1a();
virtual void foo();
virtual void bar();
};
// V-table needs to be defined weakly.
Test1a::Test1a() { use(typeid(Test1a)); }
// This defines the key function.
inline void Test1a::foo() {}
// CHECK: $_ZTV6Test1a = comdat any
// CHECK: $_ZTI6Test1a = comdat any
// CHECK: $_ZTS6Test1a = comdat any
// CHECK-NOT: $_ZTI6Test1a.1 = comdat any
// CHECK-NOT: $_ZTS6Test1a.1 = comdat any
// CHECK: @_ZTV6Test1a = linkonce_odr dso_local unnamed_addr constant {{.*}} ptr @_ZTI6Test1a
// CHECK: @_ZTI6Test1a = linkonce_odr dso_local constant {{.*}} ptr @_ZTS6Test1a
// CHECK: @_ZTS6Test1a = linkonce_odr dso_local constant