llvm-project/clang/test/CodeGenCXX/microsoft-inaccessible-base.cpp
Nikita Popov 32791f19fd [Clang] Convert some tests to opaque pointers (NFC)
These tests all require some adjustments to make sure that struct
types still get generated, mostly done by stripping pointer
indirections.

Some of this may no longer test the situation it was originally
intended for, e.g. the issue from pr18962 just doesn't really
exist anymore with opaque pointers, as we no longer generate
recursive types.
2023-06-08 16:39:57 +02:00

26 lines
1.0 KiB
C++

// RUN: %clang_cc1 -fms-compatibility -triple x86_64-windows-msvc %s -emit-llvm -o - | FileCheck %s
// Make sure we choose the *direct* base path when doing these conversions.
struct A { int a; };
struct B : A { int b; };
struct C : A, B { };
extern "C" A *a_from_c(C *p) { return p; }
// CHECK-LABEL: define dso_local ptr @a_from_c(ptr noundef %{{.*}})
// CHECK: [[P_ADDR:%.*]] = alloca ptr
// CHECK-NEXT: store ptr [[P:%.*]], ptr [[P_ADDR]]
// CHECK-NEXT: [[RET:%.*]] = load ptr, ptr [[P_ADDR]]
// CHECK-NEXT: ret ptr [[RET]]
struct D : B, A { };
extern "C" A *a_from_d(D *p) { return p; }
// CHECK-LABEL: define dso_local ptr @a_from_d(ptr noundef %{{.*}})
// CHECK: [[P_ADDR:%.*]] = alloca ptr
// CHECK-NEXT: store ptr [[P:%.*]], ptr [[P_ADDR]]
// CHECK-NEXT: [[P_RELOAD:%.*]] = load ptr, ptr [[P_ADDR]]
// CHECK-NEXT: [[CMP:%.*]] = icmp eq ptr [[P_RELOAD]], null
// CHECK: [[ADD_PTR:%.*]] = getelementptr inbounds i8, ptr [[P_RELOAD]], i64 8
// CHECK: [[RET:%.*]] = phi ptr [ [[ADD_PTR]], {{.*}} ], [ null, %entry ]
// CHECK-NEXT: ret ptr [[RET]]