Debian Codegraph @

clang/test/OpenMP/target_vtable_codegen_nested.cpp

raw
1 // RUN: %clang_cc1 -verify -fopenmp -Wno-openmp-mapping -x c++ -triple x86_64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -fopenmp-cuda-mode -emit-llvm-bc %s -o %t-ppc-host.bc -fopenmp-version=52
2 // RUN: %clang_cc1 -verify -fopenmp -Wno-openmp-mapping -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -fopenmp-cuda-mode -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -debug-info-kind=limited -fopenmp-version=52 | FileCheck %s
3 // expected-no-diagnostics
4
5 // CHECK-DAG: @_ZTV3Car
6 // CHECK-DAG: @_ZTV6Engine
7 // CHECK-DAG: @_ZTV6Wheels
8 // CHECK-DAG: @_ZTV7Vehicle
9 // CHECK-DAG: @_ZTV5Brand
10 class Engine {
11 public:
12 Engine(const char *type) : type(type) {}
13 virtual ~Engine() {}
14
15 virtual void start() const { }
16
17 protected:
18 const char *type;
19 };
20
21 class Wheels {
22 public:
23 Wheels(int count) : count(count) {}
24 virtual ~Wheels() {}
25
26 virtual void roll() const { }
27
28 protected:
29 int count;
30 };
31
32 class Vehicle {
33 public:
34 Vehicle(int speed) : speed(speed) {}
35 virtual ~Vehicle() {}
36
37 virtual void move() const { }
38
39 protected:
40 int speed;
41 };
42
43 class Brand {
44 public:
45 Brand(const char *brandName) : brandName(brandName) {}
46 virtual ~Brand() {}
47
48 void showBrand() const { }
49
50 protected:
51 const char *brandName;
52 };
53
54 class Car : public Vehicle, public Brand {
55 public:
56 Car(const char *brand, int speed, const char *engineType, int wheelCount)
57 : Vehicle(speed), Brand(brand), engine(engineType), wheels(wheelCount) {}
58
59 void move() const override { }
60
61 void drive() const {
62 showBrand();
63 engine.start();
64 wheels.roll();
65 move();
66 }
67
68 private:
69 Engine engine;
70 Wheels wheels;
71 };
72
73 int main() {
74 Car myActualCar("Ford", 100, "Hybrid", 4);
75
76 // Make sure we emit VTable for dynamic class as field
77 #pragma omp target map(myActualCar)
78 {
79 myActualCar.drive();
80 }
81 return 0;
82 }