mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-24 12:02:36 +08:00
Summary: `__libcpp_refstring` currently has two different definitions. First there is the complete definition in `<__refstring>` but there is also a second in `<stdexcept>`. The historical reason for this split is because both libc++ and libc++abi need to see the inline definitions of __libcpp_refstrings methods, but the `<stdexcept>` header doesn't. However this is an ODR violation and breaks the modules build. This patch fixes the issue by creating a single class definition in `<stdexcept>` and changing `<__refstring>` to contain only the inline method definitions. This way both `libcxx/src/stdexcept.cpp` and `libcxxabi/src/stdexcept.cpp` see the same declaration in `<stdexcept>` and definitions in `<__refstring>` Reviewers: mclow.lists, EricWF Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25603 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@285100 91177308-0d34-0410-b5e6-96231b3b80d8
104 lines
2.1 KiB
C++
104 lines
2.1 KiB
C++
//===------------------------ stdexcept.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 "stdexcept"
|
|
#include "new"
|
|
#include "string"
|
|
#include "system_error"
|
|
#include "__refstring"
|
|
|
|
/* For _LIBCPPABI_VERSION */
|
|
#if defined(LIBCXX_BUILDING_LIBCXXABI) || defined(__APPLE__) || defined(LIBCXXRT)
|
|
#include <cxxabi.h>
|
|
#endif
|
|
|
|
static_assert(sizeof(std::__libcpp_refstring) == sizeof(const char *), "");
|
|
|
|
|
|
namespace std // purposefully not using versioning namespace
|
|
{
|
|
|
|
logic_error::logic_error(const string& msg) : __imp_(msg.c_str())
|
|
{
|
|
}
|
|
|
|
logic_error::logic_error(const char* msg) : __imp_(msg)
|
|
{
|
|
}
|
|
|
|
logic_error::logic_error(const logic_error& le) _NOEXCEPT : __imp_(le.__imp_)
|
|
{
|
|
}
|
|
|
|
logic_error&
|
|
logic_error::operator=(const logic_error& le) _NOEXCEPT
|
|
{
|
|
__imp_ = le.__imp_;
|
|
return *this;
|
|
}
|
|
|
|
#if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX)
|
|
|
|
logic_error::~logic_error() _NOEXCEPT
|
|
{
|
|
}
|
|
|
|
const char*
|
|
logic_error::what() const _NOEXCEPT
|
|
{
|
|
return __imp_.c_str();
|
|
}
|
|
|
|
#endif
|
|
|
|
runtime_error::runtime_error(const string& msg) : __imp_(msg.c_str())
|
|
{
|
|
}
|
|
|
|
runtime_error::runtime_error(const char* msg) : __imp_(msg)
|
|
{
|
|
}
|
|
|
|
runtime_error::runtime_error(const runtime_error& le) _NOEXCEPT
|
|
: __imp_(le.__imp_)
|
|
{
|
|
}
|
|
|
|
runtime_error&
|
|
runtime_error::operator=(const runtime_error& le) _NOEXCEPT
|
|
{
|
|
__imp_ = le.__imp_;
|
|
return *this;
|
|
}
|
|
|
|
#if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX)
|
|
|
|
runtime_error::~runtime_error() _NOEXCEPT
|
|
{
|
|
}
|
|
|
|
const char*
|
|
runtime_error::what() const _NOEXCEPT
|
|
{
|
|
return __imp_.c_str();
|
|
}
|
|
|
|
domain_error::~domain_error() _NOEXCEPT {}
|
|
invalid_argument::~invalid_argument() _NOEXCEPT {}
|
|
length_error::~length_error() _NOEXCEPT {}
|
|
out_of_range::~out_of_range() _NOEXCEPT {}
|
|
|
|
range_error::~range_error() _NOEXCEPT {}
|
|
overflow_error::~overflow_error() _NOEXCEPT {}
|
|
underflow_error::~underflow_error() _NOEXCEPT {}
|
|
|
|
#endif
|
|
|
|
} // std
|