File tree 2 files changed +17
-4
lines changed 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change 29
29
#pragma warning(disable : 4251)
30
30
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
31
31
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
+
32
45
/* * \brief JSON (JavaScript Object Notation).
33
46
*/
34
47
namespace Json {
@@ -69,9 +82,9 @@ class JSON_API LogicError : public Exception {
69
82
};
70
83
71
84
// / used internally
72
- void throwRuntimeError (std::string const & msg);
85
+ JSONCPP_NORETURN void throwRuntimeError (std::string const & msg);
73
86
// / used internally
74
- void throwLogicError (std::string const & msg);
87
+ JSONCPP_NORETURN void throwLogicError (std::string const & msg);
75
88
76
89
/* * \brief Type of the value held by a Value object.
77
90
*/
Original file line number Diff line number Diff line change @@ -168,11 +168,11 @@ RuntimeError::RuntimeError(std::string const& msg)
168
168
LogicError::LogicError (std::string const & msg)
169
169
: Exception(msg)
170
170
{}
171
- void throwRuntimeError (std::string const & msg)
171
+ JSONCPP_NORETURN void throwRuntimeError (std::string const & msg)
172
172
{
173
173
throw RuntimeError (msg);
174
174
}
175
- void throwLogicError (std::string const & msg)
175
+ JSONCPP_NORETURN void throwLogicError (std::string const & msg)
176
176
{
177
177
throw LogicError (msg);
178
178
}
You can’t perform that action at this time.
0 commit comments