diff options
author | Shoaib Meenai <smeenai@fb.com> | 2017-03-28 19:33:31 +0000 |
---|---|---|
committer | Shoaib Meenai <smeenai@fb.com> | 2017-03-28 19:33:31 +0000 |
commit | f012f260c391937dc5810c5a640f33447a8525cd (patch) | |
tree | 9708a2c769c2a492ce345faca6bf75a4343635b7 /src | |
parent | 0b148779b383f36e7fec8d40b1956831b0ec3bd5 (diff) |
[libc++] Add a key function for bad_function_call
Summary:
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.
Guard this change behind an ABI macro, since it isn't backwards
compatible (i.e., clients built against the new libc++ headers wouldn't
be able to run against an older libc++ library).
Reviewers: mclow.lists, EricWF
Subscribers: mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D27387
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@298937 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'src')
-rw-r--r-- | src/functional.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/functional.cpp b/src/functional.cpp new file mode 100644 index 000000000..5c2646f01 --- /dev/null +++ b/src/functional.cpp @@ -0,0 +1,26 @@ +//===----------------------- 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 + +#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION +bad_function_call::~bad_function_call() _NOEXCEPT +{ +} + +const char* +bad_function_call::what() const _NOEXCEPT +{ + return "std::bad_function_call"; +} +#endif + +_LIBCPP_END_NAMESPACE_STD |