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
diff --git a/include/json/config.h b/include/json/config.h
index 3d148a6..6359273 100644
--- a/include/json/config.h
+++ b/include/json/config.h
@@ -74,20 +74,6 @@
// C++11 should be used directly in JSONCPP.
#define JSONCPP_OVERRIDE override
-#if __cplusplus >= 201103L
-#define JSONCPP_NOEXCEPT noexcept
-#define JSONCPP_OP_EXPLICIT explicit
-#elif defined(_MSC_VER) && _MSC_VER < 1900
-#define JSONCPP_NOEXCEPT throw()
-#define JSONCPP_OP_EXPLICIT explicit
-#elif defined(_MSC_VER) && _MSC_VER >= 1900
-#define JSONCPP_NOEXCEPT noexcept
-#define JSONCPP_OP_EXPLICIT explicit
-#else
-#define JSONCPP_NOEXCEPT throw()
-#define JSONCPP_OP_EXPLICIT
-#endif
-
#ifdef __clang__
#if __has_extension(attribute_deprecated_with_message)
#define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
diff --git a/include/json/value.h b/include/json/value.h
index bea2a56..dffc51a 100644
--- a/include/json/value.h
+++ b/include/json/value.h
@@ -67,8 +67,8 @@
class JSON_API Exception : public std::exception {
public:
Exception(String msg);
- ~Exception() JSONCPP_NOEXCEPT override;
- char const* what() const JSONCPP_NOEXCEPT override;
+ ~Exception() noexcept override;
+ char const* what() const noexcept override;
protected:
String msg_;
@@ -421,7 +421,7 @@
bool empty() const;
/// Return !isNull()
- JSONCPP_OP_EXPLICIT operator bool() const;
+ explicit operator bool() const;
/// Remove all object members and array elements.
/// \pre type() is arrayValue, objectValue, or nullValue