mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-04-20 07:51:32 +02:00
Merge pull request #446 from ya1gaurav/patch-37
NORETURN for throw functions in 0.x.y branch
This commit is contained in:
commit
d2fc18af7f
@ -29,6 +29,19 @@
|
|||||||
#pragma warning(disable : 4251)
|
#pragma warning(disable : 4251)
|
||||||
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||||
|
|
||||||
|
//Conditional NORETURN attribute on the throw functions would:
|
||||||
|
// a) suppress false positives from static code analysis
|
||||||
|
// b) possibly improve optimization opportunities.
|
||||||
|
#if !defined(JSONCPP_NORETURN)
|
||||||
|
# if defined(_MSC_VER)
|
||||||
|
# define JSONCPP_NORETURN __declspec(noreturn)
|
||||||
|
# elif defined(__GNUC__)
|
||||||
|
# define JSONCPP_NORETURN __attribute__ ((__noreturn__))
|
||||||
|
# else
|
||||||
|
# define JSONCPP_NORETURN
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/** \brief JSON (JavaScript Object Notation).
|
/** \brief JSON (JavaScript Object Notation).
|
||||||
*/
|
*/
|
||||||
namespace Json {
|
namespace Json {
|
||||||
@ -69,9 +82,9 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// used internally
|
/// used internally
|
||||||
void throwRuntimeError(std::string const& msg);
|
JSONCPP_NORETURN void throwRuntimeError(std::string const& msg);
|
||||||
/// used internally
|
/// used internally
|
||||||
void throwLogicError(std::string const& msg);
|
JSONCPP_NORETURN void throwLogicError(std::string const& msg);
|
||||||
|
|
||||||
/** \brief Type of the value held by a Value object.
|
/** \brief Type of the value held by a Value object.
|
||||||
*/
|
*/
|
||||||
|
@ -168,11 +168,11 @@ RuntimeError::RuntimeError(std::string const& msg)
|
|||||||
LogicError::LogicError(std::string const& msg)
|
LogicError::LogicError(std::string const& msg)
|
||||||
: Exception(msg)
|
: Exception(msg)
|
||||||
{}
|
{}
|
||||||
void throwRuntimeError(std::string const& msg)
|
JSONCPP_NORETURN void throwRuntimeError(std::string const& msg)
|
||||||
{
|
{
|
||||||
throw RuntimeError(msg);
|
throw RuntimeError(msg);
|
||||||
}
|
}
|
||||||
void throwLogicError(std::string const& msg)
|
JSONCPP_NORETURN void throwLogicError(std::string const& msg)
|
||||||
{
|
{
|
||||||
throw LogicError(msg);
|
throw LogicError(msg);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user