• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s
2 
3 struct Base {
4 
5   void no_args_1(void (*callback)(void));
6   __attribute__((callback(1))) void no_args_2(void (*callback1)(void), void (*callback2)(void));
7   __attribute__((callback(callback1))) void no_args_3(void (*callback1)(void), void (*callback2)(void));
8 
9   // TODO: There should probably be a warning or even an error for different
10   //       callbacks on the same method.
11   __attribute__((callback(1))) virtual void
12   virtual_1(void (*callback)(void));
13 
14   __attribute__((callback(callback, this, __, this))) virtual void
15   this_unknown_this(void (*callback)(Base *, Base *, Base *));
16 };
17 
18 // CHECK-DAG:      define void @_ZN4Base9no_args_1EPFvvE({{[^!]*!callback}} ![[cid0:[0-9]+]]
19 __attribute__((callback(1))) void
no_args_1(void (* callback)(void))20 Base::no_args_1(void (*callback)(void)) {
21 }
22 
23 // CHECK-DAG:      define void @_ZN4Base9no_args_2EPFvvES1_({{[^!]*!callback}} ![[cid1:[0-9]+]]
no_args_2(void (* callback1)(void),void (* callback2)(void))24 __attribute__((callback(2))) void Base::no_args_2(void (*callback1)(void), void (*callback2)(void)) {
25 }
26 // CHECK-DAG:      define void @_ZN4Base9no_args_3EPFvvES1_({{[^!]*!callback}} ![[cid1]]
no_args_3(void (* callback1)(void),void (* callback2)(void))27 __attribute__((callback(callback2))) void Base::no_args_3(void (*callback1)(void), void (*callback2)(void)) {
28 }
29 
30 // CHECK-DAG:      define void @_ZN4Base17this_unknown_thisEPFvPS_S0_S0_E({{[^!]*!callback}} ![[cid2:[0-9]+]]
this_unknown_this(void (* callback)(Base *,Base *,Base *))31 void Base::this_unknown_this(void (*callback)(Base *, Base *, Base *)) {
32 }
33 
34 struct Derived_1 : public Base {
35   __attribute__((callback(1))) virtual void
36   virtual_1(void (*callback)(void)) override;
37 };
38 
39 // CHECK-DAG:      define void @_ZN9Derived_19virtual_1EPFvvE({{[^!]*!callback}} ![[cid0]]
virtual_1(void (* callback)(void))40 void Derived_1::virtual_1(void (*callback)(void)) {}
41 
42 struct Derived_2 : public Base {
43   void virtual_1(void (*callback)(void)) override;
44 };
45 
46 // CHECK-DAG: define void @_ZN9Derived_29virtual_1EPFvvE
47 // CHECK-NOT: !callback
virtual_1(void (* callback)(void))48 void Derived_2::virtual_1(void (*callback)(void)) {}
49 
50 // CHECK-DAG: ![[cid0]] = !{![[cid0b:[0-9]+]]}
51 // CHECK-DAG: ![[cid0b]] = !{i64 1, i1 false}
52 // CHECK-DAG: ![[cid1]] = !{![[cid1b:[0-9]+]]}
53 // CHECK-DAG: ![[cid1b]] = !{i64 2, i1 false}
54 // CHECK-DAG: ![[cid2]] = !{![[cid2b:[0-9]+]]}
55 // CHECK-DAG: ![[cid2b]] = !{i64 1, i64 0, i64 -1, i64 0, i1 false}
56