================
@@ -0,0 +1,96 @@
+// For CTemplate we check in case of:
+// - Implicitly instantiate whole class by up-casting:
+// * The vtable is generated with comdat
+// * Its '_vtable$' is generated
+// - Implicitly instantiate member function only:
+// # when optimized:
+// * The vtable is vanished (no declaration)
+// * Its '_vtable$' is generated without associating to vtable
+// # when non-optimized:
+// * The vtable is generated with comdat only if non-optimized
+// * Its '_vtable$' is generated regardless optimized or not
+// - Define explicitly instantiation:
+// * The vtable is generated with comdat
+// * Its '_vtable$' is generated
+// - Declare explicitly instantiation as extern:
+// * The vtable is declared
+// * Its '_vtable$' is generated only if optimized
+
+struct CBase {
+ virtual void f() noexcept {}
+};
+
+template <typename T>
+struct CTemplate: CBase {
+ void f() noexcept override;
+ virtual ~CTemplate() noexcept;
+};
+template <typename T>
+void CTemplate<T>::f() noexcept {}
+template <typename T>
+CTemplate<T>::~CTemplate() noexcept {}
+
+#ifdef EXPLICIT
+template struct CTemplate<void>;
+#endif
+#ifdef EXTERN
+extern template struct CTemplate<void>;
+#endif
----------------
jalopezg-git wrote:
What about just
```suggestion
#if defined(EXPLICIT) || defined(EXTERN)
EXTERN template struct CTemplate<void>;
#endif
```
and specifying `-DEXTERN=extern` on the command line, where needed.
https://github.com/llvm/llvm-project/pull/151818
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits