File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed
Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change 2929#pragma warning(disable : 4251)
3030#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
3131
32+ // Conditional NORETURN attribute on the throw functions would:
33+ // a) suppress false positives from static code analysis
34+ // b) possibly improve optimization opportunities.
35+ #if !defined(JSONCPP_NORETURN)
36+ # if defined(_MSC_VER)
37+ # define JSONCPP_NORETURN __declspec (noreturn)
38+ # elif defined(__GNUC__)
39+ # define JSONCPP_NORETURN __attribute__ ((__noreturn__))
40+ # else
41+ # define JSONCPP_NORETURN
42+ # endif
43+ #endif
44+
3245/* * \brief JSON (JavaScript Object Notation).
3346 */
3447namespace Json {
@@ -69,9 +82,9 @@ class JSON_API LogicError : public Exception {
6982};
7083
7184// / used internally
72- void throwRuntimeError (std::string const & msg);
85+ JSONCPP_NORETURN void throwRuntimeError (std::string const & msg);
7386// / used internally
74- void throwLogicError (std::string const & msg);
87+ JSONCPP_NORETURN void throwLogicError (std::string const & msg);
7588
7689/* * \brief Type of the value held by a Value object.
7790 */
Original file line number Diff line number Diff line change @@ -168,11 +168,11 @@ RuntimeError::RuntimeError(std::string const& msg)
168168LogicError::LogicError (std::string const & msg)
169169 : Exception(msg)
170170{}
171- void throwRuntimeError (std::string const & msg)
171+ JSONCPP_NORETURN void throwRuntimeError (std::string const & msg)
172172{
173173 throw RuntimeError (msg);
174174}
175- void throwLogicError (std::string const & msg)
175+ JSONCPP_NORETURN void throwLogicError (std::string const & msg)
176176{
177177 throw LogicError (msg);
178178}
You can’t perform that action at this time.
0 commit comments