@@ -50,15 +50,14 @@ namespace llvm {
50
50
// / namespace llvm {
51
51
// / template<bool xcompile> class TypeBuilder<MyType, xcompile> {
52
52
// / public:
53
- // / static const StructType *get() {
54
- // / // Using the static result variable ensures that the type is
55
- // / // only looked up once .
56
- // / static const StructType *const result = StructType::get(
57
- // / TypeBuilder<types::i<32>, xcompile>::get(),
58
- // / TypeBuilder<types::i<32>*, xcompile>::get(),
59
- // / TypeBuilder<types::i<8>*[], xcompile>::get(),
53
+ // / static const StructType *get(LLVMContext &Context ) {
54
+ // / // If you cache this result, be sure to cache it separately
55
+ // / // for each LLVMContext .
56
+ // / return StructType::get(
57
+ // / TypeBuilder<types::i<32>, xcompile>::get(Context ),
58
+ // / TypeBuilder<types::i<32>*, xcompile>::get(Context ),
59
+ // / TypeBuilder<types::i<8>*[], xcompile>::get(Context ),
60
60
// / NULL);
61
- // / return result;
62
61
// / }
63
62
// /
64
63
// / // You may find this a convenient place to put some constants
@@ -72,9 +71,6 @@ namespace llvm {
72
71
// / }
73
72
// / } // namespace llvm
74
73
// /
75
- // / Using the static result variable ensures that the type is only looked up
76
- // / once.
77
- // /
78
74
// / TypeBuilder cannot handle recursive types or types you only know at runtime.
79
75
// / If you try to give it a recursive type, it will deadlock, infinitely
80
76
// / recurse, or throw a recursive_init exception.
@@ -106,9 +102,7 @@ template<typename T, bool cross> class TypeBuilder<const volatile T, cross>
106
102
template <typename T, bool cross> class TypeBuilder <T*, cross> {
107
103
public:
108
104
static const PointerType *get (LLVMContext &Context) {
109
- static const PointerType *const result =
110
- PointerType::getUnqual (TypeBuilder<T,cross>::get (Context));
111
- return result;
105
+ return PointerType::getUnqual (TypeBuilder<T,cross>::get (Context));
112
106
}
113
107
};
114
108
@@ -119,18 +113,14 @@ template<typename T, bool cross> class TypeBuilder<T&, cross> {};
119
113
template <typename T, size_t N, bool cross> class TypeBuilder <T[N], cross> {
120
114
public:
121
115
static const ArrayType *get (LLVMContext &Context) {
122
- static const ArrayType *const result =
123
- ArrayType::get (TypeBuilder<T, cross>::get (Context), N);
124
- return result;
116
+ return ArrayType::get (TypeBuilder<T, cross>::get (Context), N);
125
117
}
126
118
};
127
119
// / LLVM uses an array of length 0 to represent an unknown-length array.
128
120
template <typename T, bool cross> class TypeBuilder <T[], cross> {
129
121
public:
130
122
static const ArrayType *get (LLVMContext &Context) {
131
- static const ArrayType *const result =
132
- ArrayType::get (TypeBuilder<T, cross>::get (Context), 0 );
133
- return result;
123
+ return ArrayType::get (TypeBuilder<T, cross>::get (Context), 0 );
134
124
}
135
125
};
136
126
@@ -160,9 +150,7 @@ template<typename T, bool cross> class TypeBuilder<T[], cross> {
160
150
template <> class TypeBuilder <T, false > { \
161
151
public: \
162
152
static const IntegerType *get (LLVMContext &Context) { \
163
- static const IntegerType *const result = \
164
- IntegerType::get (Context, sizeof (T) * CHAR_BIT); \
165
- return result; \
153
+ return IntegerType::get (Context, sizeof (T) * CHAR_BIT); \
166
154
} \
167
155
}; \
168
156
template <> class TypeBuilder <T, true > { \
@@ -191,8 +179,7 @@ template<uint32_t num_bits, bool cross>
191
179
class TypeBuilder <types::i<num_bits>, cross> {
192
180
public:
193
181
static const IntegerType *get (LLVMContext &C) {
194
- static const IntegerType *const result = IntegerType::get (C, num_bits);
195
- return result;
182
+ return IntegerType::get (C, num_bits);
196
183
}
197
184
};
198
185
@@ -248,24 +235,12 @@ template<> class TypeBuilder<void*, false>
248
235
template <typename R, bool cross> class TypeBuilder <R(), cross> {
249
236
public:
250
237
static const FunctionType *get (LLVMContext &Context) {
251
- static const FunctionType *const result = create (Context);
252
- return result;
253
- }
254
-
255
- private:
256
- static const FunctionType *create (LLVMContext &Context) {
257
238
return FunctionType::get (TypeBuilder<R, cross>::get (Context), false );
258
239
}
259
240
};
260
241
template <typename R, typename A1, bool cross> class TypeBuilder <R(A1), cross> {
261
242
public:
262
243
static const FunctionType *get (LLVMContext &Context) {
263
- static const FunctionType *const result = create (Context);
264
- return result;
265
- }
266
-
267
- private:
268
- static const FunctionType *create (LLVMContext &Context) {
269
244
std::vector<const Type*> params;
270
245
params.reserve (1 );
271
246
params.push_back (TypeBuilder<A1, cross>::get (Context));
@@ -277,12 +252,6 @@ template<typename R, typename A1, typename A2, bool cross>
277
252
class TypeBuilder <R(A1, A2), cross> {
278
253
public:
279
254
static const FunctionType *get (LLVMContext &Context) {
280
- static const FunctionType *const result = create (Context);
281
- return result;
282
- }
283
-
284
- private:
285
- static const FunctionType *create (LLVMContext &Context) {
286
255
std::vector<const Type*> params;
287
256
params.reserve (2 );
288
257
params.push_back (TypeBuilder<A1, cross>::get (Context));
@@ -295,12 +264,6 @@ template<typename R, typename A1, typename A2, typename A3, bool cross>
295
264
class TypeBuilder <R(A1, A2, A3), cross> {
296
265
public:
297
266
static const FunctionType *get (LLVMContext &Context) {
298
- static const FunctionType *const result = create (Context);
299
- return result;
300
- }
301
-
302
- private:
303
- static const FunctionType *create (LLVMContext &Context) {
304
267
std::vector<const Type*> params;
305
268
params.reserve (3 );
306
269
params.push_back (TypeBuilder<A1, cross>::get (Context));
@@ -316,12 +279,6 @@ template<typename R, typename A1, typename A2, typename A3, typename A4,
316
279
class TypeBuilder <R(A1, A2, A3, A4), cross> {
317
280
public:
318
281
static const FunctionType *get (LLVMContext &Context) {
319
- static const FunctionType *const result = create (Context);
320
- return result;
321
- }
322
-
323
- private:
324
- static const FunctionType *create (LLVMContext &Context) {
325
282
std::vector<const Type*> params;
326
283
params.reserve (4 );
327
284
params.push_back (TypeBuilder<A1, cross>::get (Context));
@@ -338,12 +295,6 @@ template<typename R, typename A1, typename A2, typename A3, typename A4,
338
295
class TypeBuilder <R(A1, A2, A3, A4, A5), cross> {
339
296
public:
340
297
static const FunctionType *get (LLVMContext &Context) {
341
- static const FunctionType *const result = create (Context);
342
- return result;
343
- }
344
-
345
- private:
346
- static const FunctionType *create (LLVMContext &Context) {
347
298
std::vector<const Type*> params;
348
299
params.reserve (5 );
349
300
params.push_back (TypeBuilder<A1, cross>::get (Context));
@@ -359,25 +310,13 @@ class TypeBuilder<R(A1, A2, A3, A4, A5), cross> {
359
310
template <typename R, bool cross> class TypeBuilder <R(...), cross> {
360
311
public:
361
312
static const FunctionType *get (LLVMContext &Context) {
362
- static const FunctionType *const result = create (Context);
363
- return result;
364
- }
365
-
366
- private:
367
- static const FunctionType *create (LLVMContext &Context) {
368
313
return FunctionType::get (TypeBuilder<R, cross>::get (Context), true );
369
314
}
370
315
};
371
316
template <typename R, typename A1, bool cross>
372
317
class TypeBuilder <R(A1, ...), cross> {
373
318
public:
374
319
static const FunctionType *get (LLVMContext &Context) {
375
- static const FunctionType *const result = create (Context);
376
- return result;
377
- }
378
-
379
- private:
380
- static const FunctionType *create (LLVMContext &Context) {
381
320
std::vector<const Type*> params;
382
321
params.reserve (1 );
383
322
params.push_back (TypeBuilder<A1, cross>::get (Context));
@@ -388,12 +327,6 @@ template<typename R, typename A1, typename A2, bool cross>
388
327
class TypeBuilder <R(A1, A2, ...), cross> {
389
328
public:
390
329
static const FunctionType *get (LLVMContext &Context) {
391
- static const FunctionType *const result = create (Context);
392
- return result;
393
- }
394
-
395
- private:
396
- static const FunctionType *create (LLVMContext &Context) {
397
330
std::vector<const Type*> params;
398
331
params.reserve (2 );
399
332
params.push_back (TypeBuilder<A1, cross>::get (Context));
@@ -406,12 +339,6 @@ template<typename R, typename A1, typename A2, typename A3, bool cross>
406
339
class TypeBuilder <R(A1, A2, A3, ...), cross> {
407
340
public:
408
341
static const FunctionType *get (LLVMContext &Context) {
409
- static const FunctionType *const result = create (Context);
410
- return result;
411
- }
412
-
413
- private:
414
- static const FunctionType *create (LLVMContext &Context) {
415
342
std::vector<const Type*> params;
416
343
params.reserve (3 );
417
344
params.push_back (TypeBuilder<A1, cross>::get (Context));
@@ -427,12 +354,6 @@ template<typename R, typename A1, typename A2, typename A3, typename A4,
427
354
class TypeBuilder <R(A1, A2, A3, A4, ...), cross> {
428
355
public:
429
356
static const FunctionType *get (LLVMContext &Context) {
430
- static const FunctionType *const result = create (Context);
431
- return result;
432
- }
433
-
434
- private:
435
- static const FunctionType *create (LLVMContext &Context) {
436
357
std::vector<const Type*> params;
437
358
params.reserve (4 );
438
359
params.push_back (TypeBuilder<A1, cross>::get (Context));
@@ -449,12 +370,6 @@ template<typename R, typename A1, typename A2, typename A3, typename A4,
449
370
class TypeBuilder <R(A1, A2, A3, A4, A5, ...), cross> {
450
371
public:
451
372
static const FunctionType *get (LLVMContext &Context) {
452
- static const FunctionType *const result = create (Context);
453
- return result;
454
- }
455
-
456
- private:
457
- static const FunctionType *create (LLVMContext &Context) {
458
373
std::vector<const Type*> params;
459
374
params.reserve (5 );
460
375
params.push_back (TypeBuilder<A1, cross>::get (Context));
0 commit comments