• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef STRUCTURES_H
2 #define STRUCTURES_H
3 
4 extern "C" {
5 extern int printf(const char *restrict, ...);
6 }
7 
8 struct Val {int X; void g(); };
9 
10 struct MutableVal {
11   void constFun(int) const;
12   void nonConstFun(int, int);
13   void constFun(MutableVal &) const;
14   void constParamFun(const MutableVal &) const;
15   void nonConstParamFun(const MutableVal &);
16   int X;
17 };
18 
19 struct NonTriviallyCopyable {
20   NonTriviallyCopyable() = default;
21   // Define this constructor to make this class non-trivially copyable.
22   NonTriviallyCopyable(const NonTriviallyCopyable& Ntc);
23   int X;
24 };
25 
26 struct TriviallyCopyableButBig {
27   int X;
28   char Array[16];
29 };
30 
31 struct S {
32   typedef MutableVal *iterator;
33   typedef const MutableVal *const_iterator;
34   const_iterator begin() const;
35   const_iterator end() const;
36   const_iterator cbegin() const;
37   const_iterator cend() const;
38   iterator begin();
39   iterator end();
40 };
41 
42 struct T {
43   typedef int value_type;
44   struct iterator {
45     value_type &operator*();
46     const value_type &operator*() const;
47     iterator& operator ++();
48     bool operator!=(const iterator &other);
49     void insert(value_type);
50     value_type X;
51   };
52   iterator begin();
53   iterator end();
54 };
55 
56 struct U {
57   struct iterator {
58     Val& operator*();
59     const Val& operator*()const;
60     iterator& operator ++();
61     bool operator!=(const iterator &other);
62     Val *operator->();
63   };
64   iterator begin();
65   iterator end();
66   int X;
67 };
68 
69 struct X {
70   S Ss;
71   T Tt;
72   U Uu;
73   S getS();
74 };
75 
76 template<typename ElemType>
77 class dependent {
78  public:
79   dependent<ElemType>();
80   struct iterator_base {
81     const ElemType& operator*()const;
82     iterator_base& operator ++();
83     bool operator!=(const iterator_base &other) const;
84     const ElemType *operator->() const;
85   };
86 
87   struct iterator : iterator_base {
88     ElemType& operator*();
89     iterator& operator ++();
90     ElemType *operator->();
91   };
92 
93   typedef iterator_base const_iterator;
94   const_iterator begin() const;
95   const_iterator end() const;
96   iterator begin();
97   iterator end();
98   unsigned size() const;
99   ElemType & operator[](unsigned);
100   const ElemType & operator[](unsigned) const;
101   ElemType & at(unsigned);
102   ElemType & at(unsigned, unsigned);
103   const ElemType & at(unsigned) const;
104 
105   // Intentionally evil.
106   dependent<ElemType> operator*();
107 
108   void foo();
109   void constFoo() const;
110 };
111 
112 template<typename First, typename Second>
113 class doublyDependent{
114  public:
115   struct Value {
116     First first;
117     Second second;
118   };
119 
120   struct iterator_base {
121     const Value& operator*()const;
122     iterator_base& operator ++();
123     bool operator!=(const iterator_base &other) const;
124     const Value *operator->() const;
125   };
126 
127   struct iterator : iterator_base {
128     Value& operator*();
129     Value& operator ++();
130     Value *operator->();
131   };
132 
133   typedef iterator_base const_iterator;
134   const_iterator begin() const;
135   const_iterator end() const;
136   iterator begin();
137   iterator end();
138 };
139 
140 template<typename Contained>
141 class transparent {
142  public:
143   Contained *at();
144   Contained *operator->();
145   Contained operator*();
146 };
147 
148 template<typename IteratorType>
149 struct Nested {
150   typedef IteratorType* iterator;
151   typedef const IteratorType* const_iterator;
152   IteratorType *operator->();
153   IteratorType operator*();
154   iterator begin();
155   iterator end();
156   const_iterator begin() const;
157   const_iterator end() const;
158 };
159 
160 // Like llvm::SmallPtrSet, the iterator has a dereference operator that returns
161 // by value instead of by reference.
162 template <typename T>
163 struct PtrSet {
164   struct iterator {
165     bool operator!=(const iterator &other) const;
166     const T operator*();
167     iterator &operator++();
168   };
169   iterator begin() const;
170   iterator end() const;
171 };
172 
173 template <typename T>
174 struct TypedefDerefContainer {
175   struct iterator {
176     typedef T &deref_type;
177     bool operator!=(const iterator &other) const;
178     deref_type operator*();
179     iterator &operator++();
180   };
181   iterator begin() const;
182   iterator end() const;
183 };
184 
185 template <typename T>
186 struct RValueDerefContainer {
187   struct iterator {
188     typedef T &&deref_type;
189     bool operator!=(const iterator &other) const;
190     deref_type operator*();
191     iterator &operator++();
192   };
193   iterator begin() const;
194   iterator end() const;
195 };
196 
197 namespace Macros {
198 
199 struct MacroStruct {
200   int Arr[10];
201 };
202 static MacroStruct *MacroSt;
203 #define CONT MacroSt->
204 
205 } // namespace Macros
206 
207 #endif  // STRUCTURES_H
208