clang-tidy fixes again (#1155)
* [clang-tidy] remove redundant string initialization
Found with readability-redundant-string-init
Signed-off-by: Rosen Penev <rosenp@gmail.com>
* [clang-tidy] switch to raw strings
Easier to read.
Found with modernize-raw-string-literal
Signed-off-by: Rosen Penev <rosenp@gmail.com>
* [clang-tidy] fix performance issues
Found with performance*
Signed-off-by: Rosen Penev <rosenp@gmail.com>
* fix extra comma warnings
Found with clang's -Wextra-semi-stmt
Signed-off-by: Rosen Penev <rosenp@gmail.com>
* remove JSONCPP_OP_EXPLICIT
This codebase in C++11. No need for compatibility with C++98.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
* remove JSONCPP_NOEXCEPT
This codebase is C++11 now. No need for this macro.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
diff --git a/include/json/assertions.h b/include/json/assertions.h
index 9d93238..666fa7f 100644
--- a/include/json/assertions.h
+++ b/include/json/assertions.h
@@ -21,19 +21,19 @@
// @todo <= add detail about condition in exception
#define JSON_ASSERT(condition) \
- { \
+ do { \
if (!(condition)) { \
Json::throwLogicError("assert json failed"); \
} \
- }
+ } while (0)
#define JSON_FAIL_MESSAGE(message) \
- { \
+ do { \
OStringStream oss; \
oss << message; \
Json::throwLogicError(oss.str()); \
abort(); \
- }
+ } while (0)
#else // JSON_USE_EXCEPTION
@@ -52,8 +52,10 @@
#endif
#define JSON_ASSERT_MESSAGE(condition, message) \
- if (!(condition)) { \
- JSON_FAIL_MESSAGE(message); \
- }
+ do { \
+ if (!(condition)) { \
+ JSON_FAIL_MESSAGE(message); \
+ } \
+ } while (0)
#endif // JSON_ASSERTIONS_H_INCLUDED