14
14
using namespace llvm ;
15
15
16
16
namespace {
17
- // This class, beyond being used by the test case, a nice
18
- // demonstration of the intended usage of TrailingObjects, with a
19
- // single trailing array.
20
- class Class1 final : protected TrailingObjects<Class1, short > {
17
+ // This class, beyond being used by the test case, a nice demonstration of the
18
+ // intended usage of TrailingObjects, with a single trailing array.
19
+ class Class1 final : private TrailingObjects<Class1, short > {
21
20
friend TrailingObjects;
22
21
23
22
unsigned NumShorts;
24
23
25
24
protected:
26
- size_t numTrailingObjects (OverloadToken<short >) const { return NumShorts; }
27
-
28
25
Class1 (ArrayRef<int > ShortArray) : NumShorts(ShortArray.size()) {
29
- llvm::copy (ShortArray, getTrailingObjects<short >());
26
+ // This tests the non-templated getTrailingObjects() when using a single
27
+ // trailing type.
28
+ llvm::copy (ShortArray, getTrailingObjects ());
29
+ EXPECT_EQ (getTrailingObjects (), getTrailingObjects<short >());
30
30
}
31
31
32
32
public:
@@ -36,7 +36,8 @@ class Class1 final : protected TrailingObjects<Class1, short> {
36
36
}
37
37
void operator delete (void *Ptr) { ::operator delete (Ptr); }
38
38
39
- short get (unsigned Num) const { return getTrailingObjects<short >()[Num]; }
39
+ // This indexes into the ArrayRef<> returned by `getTrailingObjects`.
40
+ short get (unsigned Num) const { return getTrailingObjects (NumShorts)[Num]; }
40
41
41
42
unsigned numShorts () const { return NumShorts; }
42
43
@@ -49,9 +50,9 @@ class Class1 final : protected TrailingObjects<Class1, short> {
49
50
using TrailingObjects::getTrailingObjects;
50
51
};
51
52
52
- // Here, there are two singular optional object types appended. Note
53
- // that the alignment of Class2 is automatically increased to account
54
- // for the alignment requirements of the trailing objects.
53
+ // Here, there are two singular optional object types appended. Note that the
54
+ // alignment of Class2 is automatically increased to account for the alignment
55
+ // requirements of the trailing objects.
55
56
class Class2 final : protected TrailingObjects<Class2, double , short > {
56
57
friend TrailingObjects;
57
58
@@ -172,10 +173,9 @@ TEST(TrailingObjects, TwoArg) {
172
173
delete C2;
173
174
}
174
175
175
- // This test class is not trying to be a usage demo, just asserting
176
- // that three args does actually work too (it's the same code as
177
- // handles the second arg, so it's basically covered by the above, but
178
- // just in case..)
176
+ // This test class is not trying to be a usage demo, just asserting that three
177
+ // args does actually work too (it's the same code as handles the second arg, so
178
+ // it's basically covered by the above, but just in case..)
179
179
class Class3 final : public TrailingObjects<Class3, double , short , bool > {
180
180
friend TrailingObjects;
181
181
@@ -237,9 +237,9 @@ TEST(TrailingObjects, Realignment) {
237
237
}
238
238
}
239
239
240
- // Test the use of TrailingObjects with a template class. This
241
- // previously failed to compile due to a bug in MSVC's member access
242
- // control/lookup handling for OverloadToken.
240
+ // Test the use of TrailingObjects with a template class. This previously failed
241
+ // to compile due to a bug in MSVC's member access control/lookup handling for
242
+ // OverloadToken.
243
243
template <typename Derived>
244
244
class Class5Tmpl : private llvm ::TrailingObjects<Derived, float , int > {
245
245
using TrailingObjects = typename llvm::TrailingObjects<Derived, float >;
0 commit comments