[PATCH] D42220: libcxx: Move bad_cast and bad_typeid member functions inline on Windows.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 17 17:21:29 PST 2018


pcc created this revision.
pcc added reviewers: smeenai, compnerd, mclow.lists, EricWF.

This fixes a duplicate symbol error when linking against vcruntime.


https://reviews.llvm.org/D42220

Files:
  libcxx/include/typeinfo
  libcxx/src/support/runtime/exception_msvc.ipp


Index: libcxx/src/support/runtime/exception_msvc.ipp
===================================================================
--- libcxx/src/support/runtime/exception_msvc.ipp
+++ libcxx/src/support/runtime/exception_msvc.ipp
@@ -97,34 +97,6 @@
     return "bad_array_length";
 }
 
-bad_cast::bad_cast() _NOEXCEPT
-{
-}
-
-bad_cast::~bad_cast() _NOEXCEPT
-{
-}
-
-const char *
-bad_cast::what() const _NOEXCEPT
-{
-  return "std::bad_cast";
-}
-
-bad_typeid::bad_typeid() _NOEXCEPT
-{
-}
-
-bad_typeid::~bad_typeid() _NOEXCEPT
-{
-}
-
-const char *
-bad_typeid::what() const _NOEXCEPT
-{
-  return "std::bad_typeid";
-}
-
 #if defined(_LIBCPP_NO_VCRUNTIME)
 exception::~exception() _NOEXCEPT
 {
Index: libcxx/include/typeinfo
===================================================================
--- libcxx/include/typeinfo
+++ libcxx/include/typeinfo
@@ -203,18 +203,56 @@
     : public exception
 {
 public:
+#if defined(_LIBCPP_ABI_MICROSOFT)
+    _LIBCPP_INLINE_VISIBILITY
+    bad_cast() _NOEXCEPT
+    {
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    ~bad_cast() _NOEXCEPT
+    {
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    const char *
+    what() const _NOEXCEPT
+    {
+      return "std::bad_cast";
+    }
+#else
     bad_cast() _NOEXCEPT;
     virtual ~bad_cast() _NOEXCEPT;
     virtual const char* what() const _NOEXCEPT;
+#endif
 };
 
 class _LIBCPP_EXCEPTION_ABI bad_typeid
     : public exception
 {
 public:
+#if defined(_LIBCPP_ABI_MICROSOFT)
+    _LIBCPP_INLINE_VISIBILITY
+    bad_typeid() _NOEXCEPT
+    {
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    ~bad_typeid() _NOEXCEPT
+    {
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    const char *
+    what() const _NOEXCEPT
+    {
+      return "std::bad_typeid";
+    }
+#else
     bad_typeid() _NOEXCEPT;
     virtual ~bad_typeid() _NOEXCEPT;
     virtual const char* what() const _NOEXCEPT;
+#endif
 };
 
 }  // std


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42220.130333.patch
Type: text/x-patch
Size: 1876 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180118/f815bc9f/attachment.bin>


More information about the llvm-commits mailing list