Skip to content

Commit

Permalink
Drop intrinsic file/line/function attributes
Browse files Browse the repository at this point in the history
...they are part of the original proposal, but are misleading since we can't use them and need dedicated tags with different types instead
  • Loading branch information
K-ballo committed Jul 21, 2017
1 parent 776c713 commit 4307260
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 111 deletions.
31 changes: 1 addition & 30 deletions hpx/exception_info.hpp
Expand Up @@ -119,18 +119,7 @@ namespace hpx

public:
exception_info() noexcept
: _file(nullptr), _line(0), _function(nullptr)
, _data(nullptr)
{}

exception_info(char const* file, int line) noexcept
: _file(file), _line(line), _function(nullptr)
, _data(nullptr)
{}

exception_info(char const* file, int line, char const* function) noexcept
: _file(file), _line(line), _function(function)
, _data(nullptr)
: _data(nullptr)
{}

exception_info(exception_info const& other) noexcept = default;
Expand All @@ -141,21 +130,6 @@ namespace hpx

virtual ~exception_info() = default;

char const* file_name() const noexcept
{
return _file;
}

int line() const noexcept
{
return _line;
}

char const* function_name() const noexcept
{
return _function;
}

template <typename ...Tags, typename ...Types>
exception_info& set(error_info<Tags, Types>&&... tagged_values)
{
Expand All @@ -177,9 +151,6 @@ namespace hpx
}

private:
char const* _file;
unsigned int _line;
char const* _function;
node_ptr _data;
};

Expand Down
70 changes: 20 additions & 50 deletions src/exception.cpp
Expand Up @@ -563,38 +563,20 @@ namespace hpx
if (pid_ && -1 != *pid_)
strm << "{process-id}: " << *pid_ << "\n";

char const* func = xi.function_name();
if (func) {
strm << "{function}: " << *func << "\n";
}
else {
std::string const* s =
xi.get<hpx::detail::throw_function>();
if (s)
strm << "{function}: " << *s << "\n";
}
std::string const* function =
xi.get<hpx::detail::throw_function>();
if (function)
strm << "{function}: " << *function << "\n";

char const* file = xi.file_name();
if (file) {
std::string const* file =
xi.get<hpx::detail::throw_file>();
if (file)
strm << "{file}: " << *file << "\n";
}
else {
std::string const* s =
xi.get<hpx::detail::throw_file>();
if (s)
strm << "{file}: " << *s << "\n";
}

int line = xi.line();
if (line) {
strm << "{line}: " << line << "\n";
}
else {
long const* l =
xi.get<hpx::detail::throw_line>();
if (l)
strm << "{line}: " << *l << "\n";
}
long const* line =
xi.get<hpx::detail::throw_line>();
if (line)
strm << "{line}: " << *line << "\n";

bool thread_info = false;
char const* const thread_prefix = "{os-thread}: ";
Expand Down Expand Up @@ -735,14 +717,10 @@ namespace hpx
/// Return the function name from which the exception was thrown.
std::string get_error_function_name(hpx::exception_info const& xi)
{
char const* func = xi.function_name();
if (func)
return func;

std::string const* s =
std::string const* function =
xi.get<hpx::detail::throw_function>();
if (s)
return *s;
if (function)
return *function;

return std::string();
}
Expand All @@ -762,14 +740,10 @@ namespace hpx
/// exception was thrown.
std::string get_error_file_name(hpx::exception_info const& xi)
{
char const* file = xi.file_name();
if (file)
return file;

std::string const* s =
std::string const* file =
xi.get<hpx::detail::throw_file>();
if (s)
return *s;
if (file)
return *file;

return "<unknown>";
}
Expand All @@ -778,14 +752,10 @@ namespace hpx
/// which the exception was thrown.
long get_error_line_number(hpx::exception_info const& xi)
{
int line = xi.line();
if (line)
return line;

long const* l =
long const* line =
xi.get<hpx::detail::throw_line>();
if (l)
return *l;
if (line)
return *line;
return -1;
}

Expand Down
44 changes: 13 additions & 31 deletions src/util/serialize_exception.cpp
Expand Up @@ -52,38 +52,20 @@ namespace hpx { namespace serialization
std::rethrow_exception(ep);
}
catch (exception_info const& xi) {
char const* func = xi.function_name();
if (func) {
throw_function_ = *func;
}
else {
std::string const* s =
xi.get<hpx::detail::throw_function>();
if (s)
throw_function_ = *s;
}

char const* file = xi.file_name();
if (file) {
std::string const* function =
xi.get<hpx::detail::throw_function>();
if (function)
throw_function_ = *function;

std::string const* file =
xi.get<hpx::detail::throw_file>();
if (file)
throw_file_ = *file;
}
else {
std::string const* s =
xi.get<hpx::detail::throw_file>();
if (s)
throw_file_ = *s;
}

int line = xi.line();
if (line) {
throw_line_ = line;
}
else {
long const* l =
xi.get<hpx::detail::throw_line>();
if (l)
throw_line_ = *l;
}

long const* line =
xi.get<hpx::detail::throw_line>();
if (line)
throw_line_ = *line;

std::uint32_t const* locality =
xi.get<hpx::detail::throw_locality>();
Expand Down

0 comments on commit 4307260

Please sign in to comment.