[PATCH] D29880: Workaround MSVC bug when using TrailingObjects from a template.
James Y Knight via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 28 10:17:33 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296497: Workaround MSVC bug when using TrailingObjects from a template. (authored by jyknight).
Changed prior to commit:
https://reviews.llvm.org/D29880?vs=88154&id=90054#toc
Repository:
rL LLVM
https://reviews.llvm.org/D29880
Files:
llvm/trunk/include/llvm/Support/TrailingObjects.h
llvm/trunk/unittests/Support/TrailingObjectsTest.cpp
Index: llvm/trunk/include/llvm/Support/TrailingObjects.h
===================================================================
--- llvm/trunk/include/llvm/Support/TrailingObjects.h
+++ llvm/trunk/include/llvm/Support/TrailingObjects.h
@@ -294,7 +294,14 @@
public:
// Make this (privately inherited) member public.
+#ifndef _MSC_VER
using ParentType::OverloadToken;
+#else
+ // MSVC bug prevents the above from working, at least up through CL
+ // 19.10.24629.
+ template <typename T>
+ using OverloadToken = typename ParentType::template OverloadToken<T>;
+#endif
/// Returns a pointer to the trailing object array of the given type
/// (which must be one of those specified in the class template). The
Index: llvm/trunk/unittests/Support/TrailingObjectsTest.cpp
===================================================================
--- llvm/trunk/unittests/Support/TrailingObjectsTest.cpp
+++ llvm/trunk/unittests/Support/TrailingObjectsTest.cpp
@@ -236,3 +236,24 @@
reinterpret_cast<char *>(C + 1) + 1, alignof(long))));
}
}
+
+// Test the use of TrailingObjects with a template class. This
+// previously failed to compile due to a bug in MSVC's member access
+// control/lookup handling for OverloadToken.
+template <typename Derived>
+class Class5Tmpl : private llvm::TrailingObjects<Derived, float, int> {
+ using TrailingObjects = typename llvm::TrailingObjects<Derived, float>;
+ friend TrailingObjects;
+
+ size_t numTrailingObjects(
+ typename TrailingObjects::template OverloadToken<float>) const {
+ return 1;
+ }
+
+ size_t numTrailingObjects(
+ typename TrailingObjects::template OverloadToken<int>) const {
+ return 2;
+ }
+};
+
+class Class5 : public Class5Tmpl<Class5> {};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29880.90054.patch
Type: text/x-patch
Size: 1748 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170228/23d641bd/attachment.bin>
More information about the llvm-commits
mailing list