Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / decl-ref-inheritance.cpp
blob9206ee5ac936967e7f20705f602293f50591f10e
1 // RUN: %clang_cc1 -triple=x86_64-unknown-linux -emit-llvm %s -o - | FileCheck \
2 // RUN: -check-prefix=CHECK-1 %s
3 // RUN: %clang_cc1 -triple=x86_64-unknown-linux -emit-llvm %s -o - | FileCheck \
4 // RUN: -check-prefix=CHECK-2 %s
5 // RUN: %clang_cc1 -triple=x86_64-unknown-linux -emit-llvm %s -o - | FileCheck \
6 // RUN: -check-prefix=CHECK-3 %s
8 // CHECK-1: [[FOO:%.+]] = type { float }
9 struct foo {
10 float val;
13 template <typename T> struct bar : T {
16 struct baz : bar<foo> {
17 // CHECK-1: define{{.*}} float @_ZN3baz3getEv
18 // CHECK-1: {{%.+}} = getelementptr inbounds [[FOO]], ptr {{%.+}}, i32 0, i32 0
19 float get() {
20 return val;
24 int qux() {
25 auto f = baz{};
26 return f.get();
29 // CHECK-2: [[F:%.+]] = type { ptr }
30 struct f {
31 void *g;
34 template <typename j> struct k : j {
35 // CHECK-2: define{{.*}} void @_ZN1kI1fE1lEv
36 // CHECK-2: {{%.+}} = getelementptr inbounds [[F]], ptr {{%.+}}, i32 0, i32 0
37 virtual void l(){ (void)f::g; }
40 k<f> q;
42 // CHECK-3: [[BASE:%.+]] = type { i32 }
43 class Base {
44 protected:
45 int member;
48 template <typename Parent>
49 struct Subclass : public Parent {
50 // CHECK-3: define{{.*}} i32 @_ZN8SubclassI4BaseE4funcEv
51 // CHECK-3: {{%.+}} = getelementptr inbounds [[BASE]], ptr {{%.+}}, i32 0, i32 0
52 int func() { return Base::member; }
55 using Impl = Subclass<Base>;
57 int use() {
58 Impl i;
59 return i.func();