1414using namespace llvm ;
1515
1616namespace {
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 > {
2120 friend TrailingObjects;
2221
2322 unsigned NumShorts;
2423
2524protected:
26- size_t numTrailingObjects (OverloadToken<short >) const { return NumShorts; }
27-
2825 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 >());
3030 }
3131
3232public:
@@ -36,7 +36,8 @@ class Class1 final : protected TrailingObjects<Class1, short> {
3636 }
3737 void operator delete (void *Ptr) { ::operator delete (Ptr); }
3838
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]; }
4041
4142 unsigned numShorts () const { return NumShorts; }
4243
@@ -49,9 +50,9 @@ class Class1 final : protected TrailingObjects<Class1, short> {
4950 using TrailingObjects::getTrailingObjects;
5051};
5152
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.
5556class Class2 final : protected TrailingObjects<Class2, double , short > {
5657 friend TrailingObjects;
5758
@@ -172,10 +173,9 @@ TEST(TrailingObjects, TwoArg) {
172173 delete C2;
173174}
174175
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..)
179179class Class3 final : public TrailingObjects<Class3, double , short , bool > {
180180 friend TrailingObjects;
181181
@@ -237,9 +237,9 @@ TEST(TrailingObjects, Realignment) {
237237}
238238}
239239
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.
243243template <typename Derived>
244244class Class5Tmpl : private llvm ::TrailingObjects<Derived, float , int > {
245245 using TrailingObjects = typename llvm::TrailingObjects<Derived, float >;
0 commit comments