llvm-project/clang/test/CodeGenCXX/derived-cast.cpp
Nikita Popov 1b9a6e58a8 [CodeGenCXX] Convert some tests to opaque pointers (NFC)
Conversion done using the script at
https://gist.github.com/nikic/98357b71fd67756b0f064c9517b62a34.

These are tests where the conversion worked out of the box and no
manual fixup was performed.
2022-10-06 12:22:03 +02:00

27 lines
475 B
C++

// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
class A {
int a;
};
class B {
int b;
public:
A *getAsA();
};
class X : public A, public B {
int x;
};
// PR35909 - https://bugs.llvm.org/show_bug.cgi?id=35909
A *B::getAsA() {
return static_cast<X*>(this);
// CHECK-LABEL: define{{.*}} ptr @_ZN1B6getAsAEv
// CHECK: %[[THIS:.*]] = load ptr, ptr
// CHECK-NEXT: getelementptr inbounds i8, ptr %[[THIS]], i64 -4
}