smeenai created this revision.
smeenai added reviewers: EricWF, mclow.lists.
smeenai added a subscriber: cfe-commits.
Herald added a subscriber: mgorny.

bad_function_call is currently an empty class, so any object files using
that class will end up with their own copy of its typeinfo, typeinfo
name and vtable, leading to unnecessary duplication that has to be
resolved by the dynamic linker. Instead, give bad_function_call a key
function and put a definition for that key function in libc++ itself, to
centralize the typeinfo and vtable.

This is consistent with the behavior for other exception classes. The
key functions are defined in libc++ rather than libc++abi since the
class is defined in the libc++ versioning namespace, so ABI
compatibility with libstdc++ is not a concern.


https://reviews.llvm.org/D27387

Files:
  include/functional
  lib/CMakeLists.txt
  lib/abi/x86_64-apple-darwin16.0.0.abilist
  lib/abi/x86_64-unknown-linux-gnu.abilist
  src/functional.cpp

Index: src/functional.cpp
===================================================================
--- /dev/null
+++ src/functional.cpp
@@ -0,0 +1,24 @@
+//===----------------------- functional.cpp -------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "functional"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+bad_function_call::~bad_function_call() _NOEXCEPT
+{
+}
+
+const char*
+bad_function_call::what() const _NOEXCEPT
+{
+    return "std::bad_function_call";
+}
+
+_LIBCPP_END_NAMESPACE_STD
Index: lib/abi/x86_64-unknown-linux-gnu.abilist
===================================================================
--- lib/abi/x86_64-unknown-linux-gnu.abilist
+++ lib/abi/x86_64-unknown-linux-gnu.abilist
@@ -172,6 +172,7 @@
 {'is_defined': True, 'type': 'FUNC', 'name': '_ZNKSt3__115basic_streambufIcNS_11char_traitsIcEEE6getlocEv'}
 {'is_defined': True, 'type': 'FUNC', 'name': '_ZNKSt3__115basic_streambufIwNS_11char_traitsIwEEE6getlocEv'}
 {'is_defined': True, 'type': 'FUNC', 'name': '_ZNKSt3__115error_condition7messageEv'}
+{'is_defined': True, 'type': 'FUNC', 'name': '_ZNKSt3__117bad_function_call4whatEv'}
 {'is_defined': True, 'type': 'FUNC', 'name': '_ZNKSt3__117moneypunct_bynameIcLb0EE11do_groupingEv'}
 {'is_defined': True, 'type': 'FUNC', 'name': '_ZNKSt3__117moneypunct_bynameIcLb0EE13do_neg_formatEv'}
 {'is_defined': True, 'type': 'FUNC', 'name': '_ZNKSt3__117moneypunct_bynameIcLb0EE13do_pos_formatEv'}
@@ -1073,6 +1074,9 @@
 {'is_defined': True, 'type': 'FUNC', 'name': '_ZNSt3__117__widen_from_utf8ILm32EED0Ev'}
 {'is_defined': True, 'type': 'FUNC', 'name': '_ZNSt3__117__widen_from_utf8ILm32EED1Ev'}
 {'is_defined': True, 'type': 'FUNC', 'name': '_ZNSt3__117__widen_from_utf8ILm32EED2Ev'}
+{'is_defined': True, 'type': 'FUNC', 'name': '_ZNSt3__117bad_function_callD0Ev'}
+{'is_defined': True, 'type': 'FUNC', 'name': '_ZNSt3__117bad_function_callD1Ev'}
+{'is_defined': True, 'type': 'FUNC', 'name': '_ZNSt3__117bad_function_callD2Ev'}
 {'is_defined': True, 'type': 'FUNC', 'name': '_ZNSt3__117declare_reachableEPv'}
 {'is_defined': True, 'type': 'FUNC', 'name': '_ZNSt3__117iostream_categoryEv'}
 {'is_defined': True, 'type': 'FUNC', 'name': '_ZNSt3__117moneypunct_bynameIcLb0EE4initEPKc'}
@@ -1545,6 +1549,7 @@
 {'is_defined': True, 'type': 'OBJECT', 'name': '_ZTINSt3__117__assoc_sub_stateE', 'size': 24}
 {'is_defined': True, 'type': 'OBJECT', 'name': '_ZTINSt3__117__widen_from_utf8ILm16EEE', 'size': 24}
 {'is_defined': True, 'type': 'OBJECT', 'name': '_ZTINSt3__117__widen_from_utf8ILm32EEE', 'size': 24}
+{'is_defined': True, 'type': 'OBJECT', 'name': '_ZTINSt3__117bad_function_callE', 'size': 24}
 {'is_defined': True, 'type': 'OBJECT', 'name': '_ZTINSt3__117moneypunct_bynameIcLb0EEE', 'size': 24}
 {'is_defined': True, 'type': 'OBJECT', 'name': '_ZTINSt3__117moneypunct_bynameIcLb1EEE', 'size': 24}
 {'is_defined': True, 'type': 'OBJECT', 'name': '_ZTINSt3__117moneypunct_bynameIwLb0EEE', 'size': 24}
@@ -1670,6 +1675,7 @@
 {'is_defined': True, 'type': 'OBJECT', 'name': '_ZTSNSt3__117__assoc_sub_stateE', 'size': 28}
 {'is_defined': True, 'type': 'OBJECT', 'name': '_ZTSNSt3__117__widen_from_utf8ILm16EEE', 'size': 35}
 {'is_defined': True, 'type': 'OBJECT', 'name': '_ZTSNSt3__117__widen_from_utf8ILm32EEE', 'size': 35}
+{'is_defined': True, 'type': 'OBJECT', 'name': '_ZTSNSt3__117bad_function_callE', 'size': 28}
 {'is_defined': True, 'type': 'OBJECT', 'name': '_ZTSNSt3__117moneypunct_bynameIcLb0EEE', 'size': 35}
 {'is_defined': True, 'type': 'OBJECT', 'name': '_ZTSNSt3__117moneypunct_bynameIcLb1EEE', 'size': 35}
 {'is_defined': True, 'type': 'OBJECT', 'name': '_ZTSNSt3__117moneypunct_bynameIwLb0EEE', 'size': 35}
@@ -1785,6 +1791,7 @@
 {'is_defined': True, 'type': 'OBJECT', 'name': '_ZTVNSt3__117__assoc_sub_stateE', 'size': 48}
 {'is_defined': True, 'type': 'OBJECT', 'name': '_ZTVNSt3__117__widen_from_utf8ILm16EEE', 'size': 96}
 {'is_defined': True, 'type': 'OBJECT', 'name': '_ZTVNSt3__117__widen_from_utf8ILm32EEE', 'size': 96}
+{'is_defined': True, 'type': 'OBJECT', 'name': '_ZTVNSt3__117bad_function_callE', 'size': 40}
 {'is_defined': True, 'type': 'OBJECT', 'name': '_ZTVNSt3__117moneypunct_bynameIcLb0EEE', 'size': 112}
 {'is_defined': True, 'type': 'OBJECT', 'name': '_ZTVNSt3__117moneypunct_bynameIcLb1EEE', 'size': 112}
 {'is_defined': True, 'type': 'OBJECT', 'name': '_ZTVNSt3__117moneypunct_bynameIwLb0EEE', 'size': 112}
Index: lib/abi/x86_64-apple-darwin16.0.0.abilist
===================================================================
--- lib/abi/x86_64-apple-darwin16.0.0.abilist
+++ lib/abi/x86_64-apple-darwin16.0.0.abilist
@@ -182,6 +182,7 @@
 {'type': 'FUNC', 'is_defined': True, 'name': '__ZNKSt3__115basic_streambufIcNS_11char_traitsIcEEE6getlocEv'}
 {'type': 'FUNC', 'is_defined': True, 'name': '__ZNKSt3__115basic_streambufIwNS_11char_traitsIwEEE6getlocEv'}
 {'type': 'FUNC', 'is_defined': True, 'name': '__ZNKSt3__115error_condition7messageEv'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNKSt3__117bad_function_call4whatEv'}
 {'type': 'FUNC', 'is_defined': True, 'name': '__ZNKSt3__117moneypunct_bynameIcLb0EE11do_groupingEv'}
 {'type': 'FUNC', 'is_defined': True, 'name': '__ZNKSt3__117moneypunct_bynameIcLb0EE13do_neg_formatEv'}
 {'type': 'FUNC', 'is_defined': True, 'name': '__ZNKSt3__117moneypunct_bynameIcLb0EE13do_pos_formatEv'}
@@ -1146,6 +1147,9 @@
 {'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__117__widen_from_utf8ILm32EED0Ev'}
 {'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__117__widen_from_utf8ILm32EED1Ev'}
 {'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__117__widen_from_utf8ILm32EED2Ev'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__117bad_function_callD0Ev'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__117bad_function_callD1Ev'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__117bad_function_callD2Ev'}
 {'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__117declare_reachableEPv'}
 {'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__117iostream_categoryEv'}
 {'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__117moneypunct_bynameIcLb0EE4initEPKc'}
@@ -1639,6 +1643,7 @@
 {'type': 'OBJECT', 'is_defined': True, 'name': '__ZTINSt3__117__assoc_sub_stateE', 'size': 0}
 {'type': 'OBJECT', 'is_defined': True, 'name': '__ZTINSt3__117__widen_from_utf8ILm16EEE', 'size': 0}
 {'type': 'OBJECT', 'is_defined': True, 'name': '__ZTINSt3__117__widen_from_utf8ILm32EEE', 'size': 0}
+{'type': 'OBJECT', 'is_defined': True, 'name': '__ZTINSt3__117bad_function_callE', 'size': 0}
 {'type': 'OBJECT', 'is_defined': True, 'name': '__ZTINSt3__117moneypunct_bynameIcLb0EEE', 'size': 0}
 {'type': 'OBJECT', 'is_defined': True, 'name': '__ZTINSt3__117moneypunct_bynameIcLb1EEE', 'size': 0}
 {'type': 'OBJECT', 'is_defined': True, 'name': '__ZTINSt3__117moneypunct_bynameIwLb0EEE', 'size': 0}
@@ -1902,6 +1907,7 @@
 {'type': 'OBJECT', 'is_defined': True, 'name': '__ZTSNSt3__115time_get_bynameIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEEE', 'size': 0}
 {'type': 'OBJECT', 'is_defined': True, 'name': '__ZTSNSt3__115time_put_bynameIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEEE', 'size': 0}
 {'type': 'OBJECT', 'is_defined': True, 'name': '__ZTSNSt3__115time_put_bynameIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEEE', 'size': 0}
+{'type': 'OBJECT', 'is_defined': True, 'name': '__ZTSNSt3__117bad_function_callE', 'size': 0}
 {'type': 'OBJECT', 'is_defined': True, 'name': '__ZTSNSt3__117moneypunct_bynameIcLb0EEE', 'size': 0}
 {'type': 'OBJECT', 'is_defined': True, 'name': '__ZTSNSt3__117moneypunct_bynameIcLb1EEE', 'size': 0}
 {'type': 'OBJECT', 'is_defined': True, 'name': '__ZTSNSt3__117moneypunct_bynameIwLb0EEE', 'size': 0}
@@ -2174,6 +2180,7 @@
 {'type': 'OBJECT', 'is_defined': True, 'name': '__ZTVNSt3__117__assoc_sub_stateE', 'size': 0}
 {'type': 'OBJECT', 'is_defined': True, 'name': '__ZTVNSt3__117__widen_from_utf8ILm16EEE', 'size': 0}
 {'type': 'OBJECT', 'is_defined': True, 'name': '__ZTVNSt3__117__widen_from_utf8ILm32EEE', 'size': 0}
+{'type': 'OBJECT', 'is_defined': True, 'name': '__ZTVNSt3__117bad_function_callE', 'size': 0}
 {'type': 'OBJECT', 'is_defined': True, 'name': '__ZTVNSt3__117moneypunct_bynameIcLb0EEE', 'size': 0}
 {'type': 'OBJECT', 'is_defined': True, 'name': '__ZTVNSt3__117moneypunct_bynameIcLb1EEE', 'size': 0}
 {'type': 'OBJECT', 'is_defined': True, 'name': '__ZTVNSt3__117moneypunct_bynameIwLb0EEE', 'size': 0}
Index: lib/CMakeLists.txt
===================================================================
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -159,7 +159,7 @@
 split_list(LIBCXX_COMPILE_FLAGS)
 split_list(LIBCXX_LINK_FLAGS)
 
-# Add a object library that contains the compiled source files.
+# Add an object library that contains the compiled source files.
 add_library(cxx_objects OBJECT ${exclude_from_all} ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
 
 set_target_properties(cxx_objects
Index: include/functional
===================================================================
--- include/functional
+++ include/functional
@@ -1387,6 +1387,10 @@
 class _LIBCPP_EXCEPTION_ABI bad_function_call
     : public exception
 {
+public:
+    virtual ~bad_function_call() _NOEXCEPT;
+
+    virtual const char* what() const _NOEXCEPT;
 };
 
 _LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to