@@ -17,14 +17,12 @@ namespace {
17
17
// This class, beyond being used by the test case, a nice
18
18
// demonstration of the intended usage of TrailingObjects, with a
19
19
// single trailing array.
20
- class Class1 final : protected TrailingObjects<Class1, short > {
20
+ class Class1 final : private TrailingObjects<Class1, short > {
21
21
friend TrailingObjects;
22
22
23
23
unsigned NumShorts;
24
24
25
25
protected:
26
- size_t numTrailingObjects (OverloadToken<short >) const { return NumShorts; }
27
-
28
26
Class1 (ArrayRef<int > ShortArray) : NumShorts(ShortArray.size()) {
29
27
// This tests the non-templated getTrailingObjects() that returns a pointer
30
28
// when using a single trailing type.
@@ -52,18 +50,15 @@ class Class1 final : protected TrailingObjects<Class1, short> {
52
50
using TrailingObjects::getTrailingObjects;
53
51
};
54
52
55
- // Here, there are two singular optional object types appended. Note
53
+ // Here, there are two singular optional object types appended. Note
56
54
// that the alignment of Class2 is automatically increased to account
57
55
// for the alignment requirements of the trailing objects.
58
- class Class2 final : protected TrailingObjects<Class2, double , short > {
56
+ class Class2 final : private TrailingObjects<Class2, double , short > {
59
57
friend TrailingObjects;
60
58
61
59
bool HasShort, HasDouble;
62
60
63
61
protected:
64
- size_t numTrailingObjects (OverloadToken<short >) const {
65
- return HasShort ? 1 : 0 ;
66
- }
67
62
size_t numTrailingObjects (OverloadToken<double >) const {
68
63
return HasDouble ? 1 : 0 ;
69
64
}
@@ -179,14 +174,23 @@ TEST(TrailingObjects, TwoArg) {
179
174
}
180
175
181
176
// This test class is not trying to be a usage demo, just asserting
182
- // that three args does actually work too (it's the same code as
177
+ // that three args does actually work too (it's the same code that
183
178
// handles the second arg, so it's basically covered by the above, but
184
179
// just in case..)
185
- class Class3 final : public TrailingObjects<Class3, double , short , bool > {
180
+ class Class3 final : private TrailingObjects<Class3, double , short , bool > {
186
181
friend TrailingObjects;
187
182
188
183
size_t numTrailingObjects (OverloadToken<double >) const { return 1 ; }
189
184
size_t numTrailingObjects (OverloadToken<short >) const { return 1 ; }
185
+
186
+ public:
187
+ // Pull some protected members in as public, for testability.
188
+ template <typename ... Ty>
189
+ using FixedSizeStorage = TrailingObjects::FixedSizeStorage<Ty...>;
190
+
191
+ using TrailingObjects::additionalSizeToAlloc;
192
+ using TrailingObjects::getTrailingObjects;
193
+ using TrailingObjects::totalSizeToAlloc;
190
194
};
191
195
192
196
TEST (TrailingObjects, ThreeArg) {
@@ -216,9 +220,18 @@ TEST(TrailingObjects, ThreeArg) {
216
220
1 ));
217
221
}
218
222
219
- class Class4 final : public TrailingObjects<Class4, char , long > {
223
+ class Class4 final : private TrailingObjects<Class4, char , long > {
220
224
friend TrailingObjects;
221
225
size_t numTrailingObjects (OverloadToken<char >) const { return 1 ; }
226
+
227
+ public:
228
+ // Pull some protected members in as public, for testability.
229
+ template <typename ... Ty>
230
+ using FixedSizeStorage = TrailingObjects::FixedSizeStorage<Ty...>;
231
+
232
+ using TrailingObjects::additionalSizeToAlloc;
233
+ using TrailingObjects::getTrailingObjects;
234
+ using TrailingObjects::totalSizeToAlloc;
222
235
};
223
236
224
237
TEST (TrailingObjects, Realignment) {
@@ -255,11 +268,6 @@ class Class5Tmpl : private llvm::TrailingObjects<Derived, float, int> {
255
268
typename TrailingObjects::template OverloadToken<float >) const {
256
269
return 1 ;
257
270
}
258
-
259
- size_t numTrailingObjects (
260
- typename TrailingObjects::template OverloadToken<int >) const {
261
- return 2 ;
262
- }
263
271
};
264
272
265
273
class Class5 : public Class5Tmpl <Class5> {};
0 commit comments