[llvm] [LLVM][Support] Add getTrailingObjects() for single trailing type (PR #138970)

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Thu May 8 09:54:20 PDT 2025


================
@@ -14,19 +14,19 @@
 using namespace llvm;
 
 namespace {
-// This class, beyond being used by the test case, a nice
-// demonstration of the intended usage of TrailingObjects, with a
-// single trailing array.
-class Class1 final : protected TrailingObjects<Class1, short> {
+// This class, beyond being used by the test case, a nice demonstration of the
+// intended usage of TrailingObjects, with a single trailing array.
+class Class1 final : private TrailingObjects<Class1, short> {
   friend TrailingObjects;
 
   unsigned NumShorts;
 
 protected:
-  size_t numTrailingObjects(OverloadToken<short>) const { return NumShorts; }
-
   Class1(ArrayRef<int> ShortArray) : NumShorts(ShortArray.size()) {
-    llvm::copy(ShortArray, getTrailingObjects<short>());
+    // This tests the non-templated getTrailingObjects() when using a single
+    // trailing type.
+    llvm::copy(ShortArray, getTrailingObjects());
+    EXPECT_EQ(getTrailingObjects(), getTrailingObjects<short>());
----------------
dwblaikie wrote:

could this be moved into a `TEST`?

https://github.com/llvm/llvm-project/pull/138970


More information about the llvm-commits mailing list