Use [[noreturn]] instead of declspec(noreturn)

This commit is contained in:
Robert Schumacher 2017-03-31 17:19:03 -07:00 committed by Alexander Karatarakis
parent 095d3294d5
commit 31e55704f5
4 changed files with 21 additions and 10 deletions

View File

@ -5,25 +5,31 @@
namespace vcpkg::Checks
{
__declspec(noreturn) void unreachable(const LineInfo& line_info);
[[noreturn]]
void unreachable(const LineInfo& line_info);
_declspec(noreturn) void exit_with_code(const LineInfo& line_info, const int exit_code);
[[noreturn]]
void exit_with_code(const LineInfo& line_info, const int exit_code);
_declspec(noreturn) inline void exit_fail(const LineInfo& line_info)
[[noreturn]]
inline void exit_fail(const LineInfo& line_info)
{
exit_with_code(line_info, EXIT_FAILURE);
}
_declspec(noreturn) inline void exit_success(const LineInfo& line_info)
[[noreturn]]
inline void exit_success(const LineInfo& line_info)
{
exit_with_code(line_info, EXIT_SUCCESS);
}
// Part of the reason these exist is to not include extra headers in this one to avoid circular #includes.
_declspec(noreturn) void exit_with_message(const LineInfo& line_info, const cstring_view errorMessage);
[[noreturn]]
void exit_with_message(const LineInfo& line_info, const cstring_view errorMessage);
template <class Arg1, class...Args>
_declspec(noreturn) void exit_with_message(const LineInfo& line_info, const char* errorMessageTemplate, const Arg1 errorMessageArg1, const Args&... errorMessageArgs)
[[noreturn]]
void exit_with_message(const LineInfo& line_info, const char* errorMessageTemplate, const Arg1 errorMessageArg1, const Args&... errorMessageArgs)
{
exit_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArg1, errorMessageArgs...));
}

View File

@ -6,5 +6,6 @@ namespace vcpkg::Enums
{
std::string nullvalue_toString(const std::string& enum_name);
__declspec(noreturn) void nullvalue_used(const LineInfo& line_info, const std::string& enum_name);
[[noreturn]]
void nullvalue_used(const LineInfo& line_info, const std::string& enum_name);
}

View File

@ -5,7 +5,8 @@
namespace vcpkg::Checks
{
__declspec(noreturn) void unreachable(const LineInfo& line_info)
[[noreturn]]
void unreachable(const LineInfo& line_info)
{
System::println(System::color::error, "Error: Unreachable code was reached");
System::println(System::color::error, line_info.toString()); // Always print line_info here
@ -16,6 +17,7 @@ namespace vcpkg::Checks
#endif
}
[[noreturn]]
void exit_with_code(const LineInfo& line_info, const int exit_code)
{
if (g_debugging)
@ -26,7 +28,8 @@ namespace vcpkg::Checks
::exit(exit_code);
}
__declspec(noreturn) void exit_with_message(const LineInfo& line_info, const cstring_view errorMessage)
[[noreturn]]
void exit_with_message(const LineInfo& line_info, const cstring_view errorMessage)
{
System::println(System::color::error, errorMessage);
exit_fail(line_info);

View File

@ -9,7 +9,8 @@ namespace vcpkg::Enums
return Strings::format("%s_NULLVALUE", enum_name);
}
__declspec(noreturn) void nullvalue_used(const LineInfo& line_info, const std::string& enum_name)
[[noreturn]]
void nullvalue_used(const LineInfo& line_info, const std::string& enum_name)
{
Checks::exit_with_message(line_info, "NULLVALUE of enum %s was used", enum_name);
}