Compare commits

...

30 Commits

Author SHA1 Message Date
dcd2d83b34 Merge branch 'develop' 2017-05-06 10:59:01 -07:00
38cdb50eb2 Deleted N3757 2017-05-06 10:54:42 -07:00
d29b6bc1a2 Merge remote-tracking branch 'remotes/origin/develop' 2017-05-06 10:48:57 -07:00
1a0e643211 64-bit support in clone_current_exception_non_intrusive.cpp, thanks Martin Weiss 2017-04-23 18:09:22 -07:00
32d831c4b2 restoring non-intrusive exception_ptr code 2017-04-23 17:58:28 -07:00
7599ec73a2 No clang 3.0 2017-03-30 18:06:45 -07:00
e0d31c79ab Adding clang 3.0? 2017-03-30 18:01:18 -07:00
4824ef856f Merge branch 'develop' of https://github.com/boostorg/exception into develop
# Conflicts:
#	include/boost/exception/detail/error_info_impl.hpp
2017-03-30 17:22:09 -07:00
bed7f3147f Typo 2017-03-30 17:20:21 -07:00
73f3e4796e Typo 2017-03-30 17:09:43 -07:00
c8fbbb9d11 Merge branch 'develop' of https://github.com/boostorg/exception into develop 2017-03-30 16:56:29 -07:00
464e7f9d09 error_info rvalue reference constructors changed to use is_nothrow_move_constructible 2017-03-30 16:56:13 -07:00
991d600f01 Fixing bug in exception_ptr cloning of error_info objects. 2017-03-15 11:39:42 -07:00
10550b69d4 Deleting accidentally committed file. 2017-03-13 16:08:34 -07:00
cf05dc079b Removing non-intrusive exception_ptr support. 2017-03-13 15:07:09 -07:00
4ea8555871 Removed double-including of config. 2017-02-21 11:41:51 -08:00
36af19fa50 Merge branch 'develop' of https://github.com/boostorg/exception into develop 2017-02-20 18:31:48 -08:00
0eee187876 #include config before anything else 2017-02-20 18:23:36 -08:00
e8877d4837 Workaround for 11874 2017-01-03 15:25:52 -08:00
d39ba00088 Added more g++ versions to .travis.yml 2017-01-03 15:05:12 -08:00
972667f52e Tweaks to try to defeat g++4.6.3 2017-01-03 14:35:11 -08:00
406d3c87f7 Maybe fixing 11874 2017-01-03 12:17:27 -08:00
6d1c2c434b Adding c++0x to gcc command line 2017-01-03 10:42:30 -08:00
59666dcdb0 Adding missing include in error_info_basic_test.cpp 2017-01-03 00:06:25 -08:00
07d5ef529b Added error_info_basic_test.cpp to test ticket 11874 2017-01-03 00:00:52 -08:00
2cdbdfcf4e Deleting unused test/exception_hpp_test.cpp, removing c++11 from build requests. 2017-01-02 17:04:32 -08:00
32a3bda6cc Removed c++11 for g++-4.6.3 invocation. 2017-01-02 16:47:03 -08:00
119dbf688f Hopefully g++-4.6.3 will in .travis.yml now. 2017-01-02 16:42:16 -08:00
66b39f3136 removed attempting to install g++-4.6.3 in .travis.yml 2017-01-02 16:31:33 -08:00
e1fc48ef3d .travis.yml 2017-01-02 15:58:05 -08:00
23 changed files with 360 additions and 293 deletions

99
.travis.yml Normal file
View File

@ -0,0 +1,99 @@
# Copyright 2017 Emil Dotchevski
# Copyright 2016 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
language: cpp
sudo: false
python: "2.7"
os:
- linux
- osx
branches:
only:
- master
- develop
env:
matrix:
- BOGUS_JOB=true
addons:
apt:
packages:
- g++-4.7
- g++-4.8
- g++-4.9
- g++-5
- g++-6
- clang-3.6
- clang-3.7
- clang-3.8
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise
- llvm-toolchain-precise-3.6
- llvm-toolchain-precise-3.7
- llvm-toolchain-precise-3.8
matrix:
exclude:
- env: BOGUS_JOB=true
include:
- os: linux
env: TOOLSET=gcc COMPILER=g++ CXXSTD=c++0x
- os: linux
env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=c++0x
- os: linux
env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=c++0x
- os: linux
env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=c++0x
- os: linux
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=c++0x
- os: linux
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++0x
- os: linux
env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=c++0x
- os: linux
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=c++0x
- os: linux
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=c++0x
- os: osx
env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++0x
install:
- cd ..
- git clone -b $TRAVIS_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule update --init tools/build
- git submodule update --init tools/inspect
- git submodule update --init libs/config
- git submodule update --init tools/boostdep
- cp -r $TRAVIS_BUILD_DIR/* libs/exception
- python tools/boostdep/depinst/depinst.py exception
- ./bootstrap.sh
- ./b2 headers
script:
- |-
echo "using $TOOLSET : : $COMPILER : <cxxflags>-std=$CXXSTD ;" > ~/user-config.jam
- ./b2 libs/exception/test toolset=$TOOLSET
notifications:
email:
on_success: always

View File

@ -1,46 +0,0 @@
//Copyright (c) 2006-2013 Emil Dotchevski and Reverge Studios, Inc.
//Distributed under the Boost Software License, Version 1.0. (See accompanying
//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef UUID_9011016A11A711E3B46CD9FA6088709B
#define UUID_9011016A11A711E3B46CD9FA6088709B
#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma GCC system_header
#endif
#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma warning(push,1)
#endif
#include <boost/exception/info.hpp>
#include <boost/exception/get_error_info.hpp>
namespace
boost
{
//Here we're using the boost::error_info machinery to store the info in the exception
//object. Within the context of N3757, this is strictly an implementation detail.
template <class Tag>
inline
void
exception::
set( typename Tag::type const & v )
{
exception_detail::set_info(*this,error_info<Tag,typename Tag::type>(v));
}
template <class Tag>
inline
typename Tag::type const *
exception::
get() const
{
return get_error_info<error_info<Tag,typename Tag::type> >(*this);
}
}
#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma warning(pop)
#endif
#endif

View File

@ -5,13 +5,8 @@
#ifndef UUID_316FDA946C0D11DEA9CBAE5255D89593
#define UUID_316FDA946C0D11DEA9CBAE5255D89593
#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma GCC system_header
#endif
#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma warning(push,1)
#endif
#include <boost/config.hpp>
#include <boost/exception/diagnostic_information.hpp>
#include <boost/exception/error_info.hpp>
#include <boost/exception/exception.hpp>
@ -29,8 +24,4 @@
#include <boost/exception/errinfo_nested_exception.hpp>
#include <boost/exception_ptr.hpp>
#endif
#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma warning(pop)
#endif
#endif

View File

@ -5,6 +5,14 @@
#ifndef UUID_CE6983AC753411DDA764247956D89593
#define UUID_CE6983AC753411DDA764247956D89593
#include <boost/config.hpp>
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
#include <boost/type_traits/is_nothrow_move_constructible.hpp>
#endif
#include <utility>
#include <string>
#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma GCC system_header
#endif
@ -12,10 +20,6 @@
#pragma warning(push,1)
#endif
#include <boost/config.hpp>
#include <utility>
#include <string>
namespace
boost
{
@ -28,8 +32,7 @@ boost
public:
virtual std::string name_value_string() const = 0;
protected:
virtual error_info_base * clone() const = 0;
virtual
~error_info_base() throw()
@ -43,39 +46,53 @@ boost
error_info:
public exception_detail::error_info_base
{
error_info_base *
clone() const
{
return new error_info<Tag,T>(*this);
}
public:
typedef T value_type;
error_info( value_type const & value );
error_info( value_type const & v ):
v_(v)
{
}
#if (__GNUC__*100+__GNUC_MINOR__!=406) //workaround for g++ bug
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
error_info( error_info const & );
error_info( value_type && value ) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(value_type(std::move(value))));
error_info( error_info && x ) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(value_type(std::move(x.value_))));
error_info( error_info const & x ):
v_(x.v_)
{
}
error_info( T && v ) BOOST_NOEXCEPT_IF(boost::is_nothrow_move_constructible<T>::value):
v_(std::move(v))
{
}
error_info( error_info && x ) BOOST_NOEXCEPT_IF(boost::is_nothrow_move_constructible<T>::value):
v_(std::move(x.v_))
{
}
#endif
~error_info() throw();
#endif
~error_info() throw()
{
}
value_type const &
value() const
{
return value_;
return v_;
}
value_type &
value()
{
return value_;
return v_;
}
private:
error_info & operator=( error_info const & );
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
error_info & operator=( error_info && x );
#endif
std::string name_value_string() const;
value_type value_;
value_type v_;
};
}

View File

@ -5,12 +5,6 @@
#ifndef UUID_618474C2DE1511DEB74A388C56D89593
#define UUID_618474C2DE1511DEB74A388C56D89593
#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma GCC system_header
#endif
#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma warning(push,1)
#endif
#include <boost/config.hpp>
#ifdef BOOST_NO_EXCEPTIONS
@ -19,8 +13,8 @@
#include <boost/exception/exception.hpp>
#include <boost/exception/info.hpp>
#include <boost/exception/diagnostic_information.hpp>
#include <boost/exception/detail/type_info.hpp>
#include <boost/exception/detail/clone_current_exception.hpp>
#include <boost/exception/detail/type_info.hpp>
#ifndef BOOST_NO_RTTI
#include <boost/core/demangle.hpp>
#endif
@ -30,6 +24,13 @@
#include <ios>
#include <stdlib.h>
#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma GCC system_header
#endif
#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma warning(push,1)
#endif
namespace
boost
{
@ -394,7 +395,7 @@ boost
{
return exception_detail::current_exception_std_exception(e);
}
#ifndef BOOST_NO_TYPEID
#ifndef BOOST_NO_TYPEID
catch(
std::bad_cast & e )
{
@ -405,7 +406,7 @@ boost
{
return exception_detail::current_exception_std_exception(e);
}
#endif
#endif
catch(
std::bad_exception & e )
{

View File

@ -5,6 +5,9 @@
#ifndef UUID_898984B4076411DD973EDFA055D89593
#define UUID_898984B4076411DD973EDFA055D89593
#include <ostream>
#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma GCC system_header
#endif
@ -12,8 +15,6 @@
#pragma warning(push,1)
#endif
#include <ostream>
namespace
boost
{

View File

@ -5,12 +5,6 @@
#ifndef UUID_6F463AC838DF11DDA3E6909F56D89593
#define UUID_6F463AC838DF11DDA3E6909F56D89593
#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma GCC system_header
#endif
#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma warning(push,1)
#endif
#include <boost/exception/detail/type_info.hpp>
#include <iomanip>
@ -19,6 +13,13 @@
#include <sstream>
#include <cstdlib>
#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma GCC system_header
#endif
#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma warning(push,1)
#endif
namespace
boost
{

View File

@ -5,6 +5,13 @@
#ifndef UUID_C3E1741C754311DDB2834CCA55D89593
#define UUID_C3E1741C754311DDB2834CCA55D89593
#include <boost/config.hpp>
#include <boost/core/typeinfo.hpp>
#include <boost/core/demangle.hpp>
#include <boost/current_function.hpp>
#include <string>
#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma GCC system_header
#endif
@ -12,12 +19,6 @@
#pragma warning(push,1)
#endif
#include <boost/core/typeinfo.hpp>
#include <boost/core/demangle.hpp>
#include <boost/current_function.hpp>
#include <boost/config.hpp>
#include <string>
namespace
boost
{

View File

@ -5,12 +5,6 @@
#ifndef UUID_0552D49838DD11DD90146B8956D89593
#define UUID_0552D49838DD11DD90146B8956D89593
#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma GCC system_header
#endif
#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma warning(push,1)
#endif
#include <boost/config.hpp>
#include <boost/exception/get_error_info.hpp>
@ -22,9 +16,18 @@
#include <exception>
#include <sstream>
#include <string>
#ifndef BOOST_NO_EXCEPTIONS
#include <boost/exception/current_exception_cast.hpp>
#endif
#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma GCC system_header
#endif
#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma warning(push,1)
#endif
#ifndef BOOST_NO_EXCEPTIONS
namespace
boost
{

View File

@ -3,4 +3,9 @@
//Distributed under the Boost Software License, Version 1.0. (See accompanying
//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef UUID_851700A4F7CF11E6B2EE06DD14915323
#define UUID_851700A4F7CF11E6B2EE06DD14915323
#include <boost/exception/exception.hpp>
#endif

View File

@ -3,4 +3,9 @@
//Distributed under the Boost Software License, Version 1.0. (See accompanying
//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef UUID_A0F7404AF7CF11E6908227DD14915323
#define UUID_A0F7404AF7CF11E6908227DD14915323
#include <boost/exception/exception.hpp>
#endif

View File

@ -5,6 +5,11 @@
#ifndef UUID_F0EE17BE6C1211DE87FF459155D89593
#define UUID_F0EE17BE6C1211DE87FF459155D89593
#include <boost/exception/info.hpp>
#include <errno.h>
#include <string.h>
#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma GCC system_header
#endif
@ -13,10 +18,6 @@
#pragma warning(disable:4996)
#endif
#include <boost/exception/info.hpp>
#include <errno.h>
#include <string.h>
namespace
boost
{

View File

@ -5,6 +5,14 @@
#ifndef UUID_1A590226753311DD9E4CCF6156D89593
#define UUID_1A590226753311DD9E4CCF6156D89593
#include <boost/config.hpp>
#include <boost/exception/exception.hpp>
#include <boost/exception/detail/error_info_impl.hpp>
#include <boost/exception/detail/type_info.hpp>
#include <boost/exception/detail/shared_ptr.hpp>
#include <boost/assert.hpp>
#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma GCC system_header
#endif
@ -12,12 +20,6 @@
#pragma warning(push,1)
#endif
#include <boost/exception/exception.hpp>
#include <boost/exception/detail/error_info_impl.hpp>
#include <boost/exception/detail/type_info.hpp>
#include <boost/exception/detail/shared_ptr.hpp>
#include <boost/assert.hpp>
namespace
boost
{

View File

@ -5,6 +5,14 @@
#ifndef UUID_8D22C4CA9CC811DCAA9133D256D89593
#define UUID_8D22C4CA9CC811DCAA9133D256D89593
#include <boost/config.hpp>
#include <boost/exception/exception.hpp>
#include <boost/exception/to_string_stub.hpp>
#include <boost/exception/detail/error_info_impl.hpp>
#include <boost/exception/detail/shared_ptr.hpp>
#include <map>
#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma GCC system_header
#endif
@ -12,13 +20,6 @@
#pragma warning(push,1)
#endif
#include <boost/exception/exception.hpp>
#include <boost/exception/to_string_stub.hpp>
#include <boost/exception/detail/error_info_impl.hpp>
#include <boost/exception/detail/shared_ptr.hpp>
#include <boost/config.hpp>
#include <map>
namespace
boost
{
@ -38,45 +39,6 @@ boost
return '[' + error_info_name(x) + "] = " + to_string_stub(x.value()) + '\n';
}
template <class Tag,class T>
inline
error_info<Tag,T>::
error_info( value_type const & value ):
value_(value)
{
}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
template <class Tag,class T>
inline
error_info<Tag,T>::
error_info( error_info const & x ):
value_(x.value_)
{
}
template <class Tag,class T>
inline
error_info<Tag,T>::
error_info( value_type && value ) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(value_type(std::move(value)))):
value_(std::move(value))
{
}
template <class Tag,class T>
inline
error_info<Tag,T>::
error_info( error_info && x ) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(value_type(std::move(x.value_)))):
value_(std::move(x.value_))
{
}
#endif
template <class Tag,class T>
inline
error_info<Tag,T>::
~error_info() throw()
{
}
template <class Tag,class T>
inline
std::string
@ -180,7 +142,11 @@ boost
refcount_ptr<error_info_container> p;
error_info_container_impl * c=new error_info_container_impl;
p.adopt(c);
c->info_ = info_;
for( error_info_map::const_iterator i=info_.begin(),e=info_.end(); i!=e; ++i )
{
shared_ptr<error_info_base> cp(i->second->clone());
c->info_.insert(std::make_pair(i->first,cp));
}
return p;
}
};

View File

@ -5,6 +5,10 @@
#ifndef UUID_63EE924290FB11DC87BB856555D89593
#define UUID_63EE924290FB11DC87BB856555D89593
#include <boost/exception/info.hpp>
#include <boost/tuple/tuple.hpp>
#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma GCC system_header
#endif
@ -12,9 +16,6 @@
#pragma warning(push,1)
#endif
#include <boost/exception/info.hpp>
#include <boost/tuple/tuple.hpp>
namespace
boost
{

View File

@ -5,6 +5,11 @@
#ifndef UUID_7E48761AD92811DC9011477D56D89593
#define UUID_7E48761AD92811DC9011477D56D89593
#include <boost/utility/enable_if.hpp>
#include <boost/exception/detail/is_output_streamable.hpp>
#include <sstream>
#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma GCC system_header
#endif
@ -12,10 +17,6 @@
#pragma warning(push,1)
#endif
#include <boost/utility/enable_if.hpp>
#include <boost/exception/detail/is_output_streamable.hpp>
#include <sstream>
namespace
boost
{

View File

@ -5,6 +5,11 @@
#ifndef UUID_E788439ED9F011DCB181F25B55D89593
#define UUID_E788439ED9F011DCB181F25B55D89593
#include <boost/exception/to_string.hpp>
#include <boost/exception/detail/object_hex_dump.hpp>
#include <boost/assert.hpp>
#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma GCC system_header
#endif
@ -12,10 +17,6 @@
#pragma warning(push,1)
#endif
#include <boost/exception/to_string.hpp>
#include <boost/exception/detail/object_hex_dump.hpp>
#include <boost/assert.hpp>
namespace
boost
{

View File

@ -10,18 +10,17 @@
#error This file requires exception handling to be enabled.
#endif
#include <boost/config.hpp>
#include <boost/exception/detail/clone_current_exception.hpp>
#if defined(BOOST_ENABLE_NON_INTRUSIVE_EXCEPTION_PTR) && defined(_MSC_VER) && defined(_M_IX86) && !defined(_M_X64)
#if defined(BOOST_ENABLE_NON_INTRUSIVE_EXCEPTION_PTR) && defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
//Non-intrusive cloning support implemented below, only for MSVC versions mentioned above.
//Thanks Anthony Williams!
//Thanks to Martin Weiss for implementing 64-bit support!
#include <boost/exception/exception.hpp>
#include <boost/shared_ptr.hpp>
#ifndef BOOST_NO_RTTI
#include <typeinfo>
#endif
#include <windows.h>
#include <malloc.h>
@ -32,8 +31,10 @@ namespace
#if _MSC_VER==1310
int const exception_info_offset=0x74;
#elif (_MSC_VER==1400 || _MSC_VER==1500)
#elif ((_MSC_VER==1400 || _MSC_VER==1500) && !defined _M_X64)
int const exception_info_offset=0x80;
#elif ((_MSC_VER==1400 || _MSC_VER==1500) && defined _M_X64)
int const exception_info_offset=0xE0;
#else
int const exception_info_offset=-1;
#endif
@ -58,7 +59,11 @@ namespace
unsigned const cpp_exception_code=0xE06D7363;
unsigned const cpp_exception_magic_flag=0x19930520;
#ifdef _M_X64
unsigned const cpp_exception_parameter_count=4;
#else
unsigned const cpp_exception_parameter_count=3;
#endif
struct
dummy_exception_type
@ -72,10 +77,18 @@ namespace
union
cpp_copy_constructor
{
void * address;
normal_copy_constructor_ptr normal_copy_constructor;
copy_constructor_with_virtual_base_ptr copy_constructor_with_virtual_base;
};
union
cpp_destructor
{
void * address;
destructor_ptr destructor;
};
enum
cpp_type_flags
{
@ -83,45 +96,46 @@ namespace
class_has_virtual_base=4
};
// ATTENTION: On x86 fields such as type_info and copy_constructor are really pointers
// but on 64bit these are 32bit offsets from HINSTANCE. Hints on the 64bit handling from
// http://blogs.msdn.com/b/oldnewthing/archive/2010/07/30/10044061.aspx .
struct
cpp_type_info
{
unsigned flags;
#ifndef BOOST_NO_RTTI
void const * type_info;
#else
std::type_info * type_info;
#endif
int type_info;
int this_offset;
int vbase_descr;
int vbase_offset;
unsigned long size;
cpp_copy_constructor copy_constructor;
int copy_constructor;
};
struct
cpp_type_info_table
{
unsigned count;
const cpp_type_info * info[1];
int info;
};
struct
cpp_exception_type
{
unsigned flags;
destructor_ptr destructor;
void(*custom_handler)();
cpp_type_info_table const * type_info_table;
int destructor;
int custom_handler;
int type_info_table;
};
struct
exception_object_deleter
{
cpp_exception_type const & et_;
size_t image_base_;
exception_object_deleter( cpp_exception_type const & et ):
et_(et)
exception_object_deleter( cpp_exception_type const & et, size_t image_base ):
et_(et),
image_base_(image_base)
{
}
@ -129,45 +143,54 @@ namespace
operator()( void * obj )
{
BOOST_ASSERT(obj!=0);
dummy_exception_type * dummy_exception_ptr=reinterpret_cast<dummy_exception_type *>(obj);
(dummy_exception_ptr->*(et_.destructor))();
dummy_exception_type* dummy_exception_ptr = static_cast<dummy_exception_type *>(obj);
if( et_.destructor )
{
cpp_destructor destructor;
destructor.address = reinterpret_cast<void *>(et_.destructor + image_base_);
(dummy_exception_ptr->*(destructor.destructor))();
}
free(obj);
}
};
cpp_type_info const &
get_cpp_type_info( cpp_exception_type const & et )
get_cpp_type_info( cpp_exception_type const & et, size_t image_base )
{
cpp_type_info const * ti = et.type_info_table->info[0];
cpp_type_info_table * const typearray = reinterpret_cast<cpp_type_info_table * const>(et.type_info_table + image_base);
cpp_type_info * const ti = reinterpret_cast<cpp_type_info * const>(typearray->info + image_base);
BOOST_ASSERT(ti!=0);
return *ti;
}
void
copy_msvc_exception( void * dst, void * src, cpp_type_info const & ti )
copy_msvc_exception( void * dst, void * src, cpp_type_info const & ti, size_t image_base )
{
if( !(ti.flags & class_is_simple_type) && ti.copy_constructor.normal_copy_constructor )
cpp_copy_constructor copy_constructor;
copy_constructor.address = reinterpret_cast<void *>(ti.copy_constructor + image_base);
if( !(ti.flags & class_is_simple_type) && copy_constructor.normal_copy_constructor )
{
dummy_exception_type * dummy_exception_ptr = reinterpret_cast<dummy_exception_type *>(dst);
dummy_exception_type * dummy_exception_ptr = static_cast<dummy_exception_type *>(dst);
if( ti.flags & class_has_virtual_base )
(dummy_exception_ptr->*(ti.copy_constructor.copy_constructor_with_virtual_base))(src,dst);
(dummy_exception_ptr->*(copy_constructor.copy_constructor_with_virtual_base))(src,dst);
else
(dummy_exception_ptr->*(ti.copy_constructor.normal_copy_constructor))(src);
(dummy_exception_ptr->*(copy_constructor.normal_copy_constructor))(src);
}
else
memmove(dst,src,ti.size);
}
boost::shared_ptr<void>
clone_msvc_exception( void * src, cpp_exception_type const & et )
clone_msvc_exception( void * src, cpp_exception_type const & et, size_t image_base )
{
assert(src!=0);
cpp_type_info const & ti=get_cpp_type_info(et);
BOOST_ASSERT(src!=0);
cpp_type_info const & ti=get_cpp_type_info(et,image_base);
if( void * dst = malloc(ti.size) )
{
try
{
copy_msvc_exception(dst,src,ti);
copy_msvc_exception(dst,src,ti,image_base);
}
catch(
... )
@ -175,7 +198,7 @@ namespace
free(dst);
throw;
}
return boost::shared_ptr<void>(dst,exception_object_deleter(et));
return boost::shared_ptr<void>(dst,exception_object_deleter(et,image_base));
}
else
throw std::bad_alloc();
@ -189,13 +212,21 @@ namespace
cloned_exception & operator=( cloned_exception const & );
cpp_exception_type const & et_;
size_t image_base_;
boost::shared_ptr<void> exc_;
public:
cloned_exception( EXCEPTION_RECORD const * record ):
et_(*reinterpret_cast<cpp_exception_type const *>(record->ExceptionInformation[2])),
image_base_((cpp_exception_parameter_count==4) ? record->ExceptionInformation[3] : 0),
exc_(clone_msvc_exception(reinterpret_cast<void *>(record->ExceptionInformation[1]),et_,image_base_))
{
}
cloned_exception( void * exc, cpp_exception_type const & et ):
cloned_exception( void * exc, cpp_exception_type const & et, size_t image_base ):
et_(et),
exc_(clone_msvc_exception(exc,et_))
image_base_(image_base),
exc_(clone_msvc_exception(exc,et_,image_base))
{
}
@ -206,19 +237,22 @@ namespace
boost::exception_detail::clone_base const *
clone() const
{
return new cloned_exception(exc_.get(),et_);
return new cloned_exception(exc_.get(),et_,image_base_);
}
void
rethrow() const
{
cpp_type_info const & ti=get_cpp_type_info(et_);
cpp_type_info const & ti=get_cpp_type_info(et_,image_base_);
void * dst = _alloca(ti.size);
copy_msvc_exception(dst,exc_.get(),ti);
copy_msvc_exception(dst,exc_.get(),ti,image_base_);
ULONG_PTR args[cpp_exception_parameter_count];
args[0]=cpp_exception_magic_flag;
args[1]=reinterpret_cast<ULONG_PTR>(dst);
args[2]=reinterpret_cast<ULONG_PTR>(&et_);
if (cpp_exception_parameter_count==4)
args[3]=image_base_;
RaiseException(cpp_exception_code,EXCEPTION_NONCONTINUABLE,cpp_exception_parameter_count,args);
}
};
@ -237,8 +271,7 @@ namespace
{
BOOST_ASSERT(exception_info_offset>=0);
BOOST_ASSERT(info_!=0);
EXCEPTION_POINTERS * info=reinterpret_cast<EXCEPTION_POINTERS *>(info_);
EXCEPTION_RECORD * record=info->ExceptionRecord;
EXCEPTION_RECORD* record = static_cast<EXCEPTION_POINTERS *>(info_)->ExceptionRecord;
if( is_cpp_exception(record) )
{
if( !record->ExceptionInformation[2] )
@ -246,9 +279,7 @@ namespace
if( is_cpp_exception(record) && record->ExceptionInformation[2] )
try
{
ptr = new cloned_exception(
reinterpret_cast<void *>(record->ExceptionInformation[1]),
*reinterpret_cast<cpp_exception_type const *>(record->ExceptionInformation[2]));
ptr = new cloned_exception(record);
result = boost::exception_detail::clone_current_exception_result::success;
}
catch(
@ -301,8 +332,6 @@ boost
//On all other compilers, return clone_current_exception_result::not_supported.
//On such platforms, only the intrusive enable_current_exception() cloning will work.
#include <boost/config.hpp>
namespace
boost
{

View File

@ -34,6 +34,7 @@ run exception_test.cpp ;
run enable_error_info_test.cpp helper1.cpp ;
run throw_exception_test.cpp helper2.cpp ;
run errno_test.cpp ;
run error_info_basic_test.cpp ;
run error_info_lv_test.cpp ;
run error_info_lv_const_test.cpp ;
run error_info_rv_test.cpp ;
@ -45,7 +46,6 @@ run no_exceptions_test.cpp : : : <exception-handling>off ;
run errinfos_test.cpp ;
run exception_ptr_test.cpp/<define>BOOST_ENABLE_NON_INTRUSIVE_EXCEPTION_PTR ../../thread/src/tss_null.cpp /boost/exception /boost//thread : : : <threading>multi : non_intrusive_exception_ptr_test ;
run exception_ptr_test.cpp ../../thread/src/tss_null.cpp /boost//thread : : : <threading>multi ;
run N3757_test.cpp ;
compile-fail exception_fail.cpp ;
compile-fail throw_exception_fail.cpp ;

View File

@ -1,67 +0,0 @@
//Copyright (c) 2006-2013 Emil Dotchevski and Reverge Studios, Inc.
//Distributed under the Boost Software License, Version 1.0. (See accompanying
//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//This file tests the N3757 syntax for adding error info to std::exception, which is
//different from the syntax used by Boost Exception.
#include <boost/exception/N3757.hpp>
#include <boost/exception/diagnostic_information.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <ostream>
struct tag1 { typedef int type; };
struct tag2 { typedef std::string type; };
struct tag3 { typedef int type; };
struct my_error_code { int ec; my_error_code(int ec):ec(ec){ } };
struct tag_error_code { typedef my_error_code type; };
bool my_error_code_to_string_called=false;
std::ostream &
operator<<( std::ostream & s, my_error_code const & x )
{
my_error_code_to_string_called=true;
return s << "my_error_code(" << x.ec << ')';
}
struct my_exception: virtual std::exception, virtual boost::exception { };
int
main()
{
try
{
throw my_exception();
}
catch(
boost::exception & e )
{
e.set<tag1>(42);
e.set<tag2>("42");
e.set<tag_error_code>(42); //Implicit conversion
try
{
throw;
}
catch(
my_exception & e )
{
BOOST_TEST(e.get<tag1>() && *e.get<tag1>()==42);
BOOST_TEST(e.get<tag2>() && *e.get<tag2>()=="42");
BOOST_TEST(!e.get<tag3>());
BOOST_TEST(e.get<tag_error_code>() && e.get<tag_error_code>()->ec==42);
//Below we're verifying that an error code wrapped in a user-defined type
//invokes the correct op<< to convert the error code to string.
//Note that N3757 diagnostic_information uses different syntax, it is a
//member of of std::exception.
std::string di=boost::diagnostic_information(e);
BOOST_TEST(!di.empty());
BOOST_TEST(my_error_code_to_string_called);
}
}
return boost::report_errors();
}

View File

@ -0,0 +1,29 @@
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
//Distributed under the Boost Software License, Version 1.0. (See accompanying
//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/exception/error_info.hpp>
#include <boost/exception/exception.hpp>
#include <boost/exception/info.hpp>
#include <boost/exception/get_error_info.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <string>
#include <string.h>
struct my_exception: virtual boost::exception {};
typedef boost::error_info<struct error_info_string_, std::string> error_info_string;
int
main()
{
try
{
throw my_exception() << error_info_string("doh");
}
catch( my_exception & e )
{
BOOST_TEST(boost::get_error_info<error_info_string>(e) && !strcmp(boost::get_error_info<error_info_string>(e)->c_str(),"doh"));
}
return 0;
}

View File

@ -1,7 +0,0 @@
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
//Distributed under the Boost Software License, Version 1.0. (See accompanying
//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/exception.hpp>
#include <boost/exception.hpp>

View File

@ -121,9 +121,42 @@ check( boost::shared_ptr<thread_handle> const & t )
}
}
void
test_deep_copy()
{
int const * p1=0;
boost::exception_ptr p;
try
{
BOOST_THROW_EXCEPTION(exc() << answer(42));
BOOST_ERROR("BOOST_THROW_EXCEPTION didn't throw");
}
catch(
exc & e )
{
p1=boost::get_error_info<answer>(e);
p=boost::current_exception();
}
BOOST_TEST(p1!=0);
BOOST_TEST(p);
try
{
boost::rethrow_exception(p);
BOOST_ERROR("rethrow_exception didn't throw");
}
catch(
exc & e )
{
int const * p2=boost::get_error_info<answer>(e);
BOOST_TEST(p2!=0 && *p2==42);
BOOST_TEST(p2!=p1);
}
}
int
main()
{
test_deep_copy();
BOOST_TEST(++exc_count==1);
try
{