From 3c5930dd8e0ed6622b34799ef98f59ef75813460 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Wed, 6 Apr 2022 22:22:23 +0200 Subject: [PATCH] Put arguments in parantheses in assert macro definitions --- liblangutil/Exceptions.h | 16 ++++++++-------- libsmtutil/Exceptions.h | 6 +++--- libsolutil/Assertions.h | 4 ++-- libsolutil/Exceptions.h | 2 +- libyul/Exceptions.h | 6 +++--- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/liblangutil/Exceptions.h b/liblangutil/Exceptions.h index 10fca8029..fb6f23cf1 100644 --- a/liblangutil/Exceptions.h +++ b/liblangutil/Exceptions.h @@ -58,13 +58,13 @@ struct InvalidAstError: virtual util::Exception {}; #endif #define solAssert_1(CONDITION) \ - solAssert_2(CONDITION, "") + solAssert_2((CONDITION), "") #define solAssert_2(CONDITION, DESCRIPTION) \ assertThrowWithDefaultDescription( \ - CONDITION, \ + (CONDITION), \ ::solidity::langutil::InternalCompilerError, \ - DESCRIPTION, \ + (DESCRIPTION), \ "Solidity assertion failed" \ ) @@ -77,13 +77,13 @@ struct InvalidAstError: virtual util::Exception {}; #endif #define solUnimplementedAssert_1(CONDITION) \ - solUnimplementedAssert_2(CONDITION, "") + solUnimplementedAssert_2((CONDITION), "") #define solUnimplementedAssert_2(CONDITION, DESCRIPTION) \ assertThrowWithDefaultDescription( \ - CONDITION, \ + (CONDITION), \ ::solidity::langutil::UnimplementedFeatureError, \ - DESCRIPTION, \ + (DESCRIPTION), \ "Unimplemented feature" \ ) @@ -105,9 +105,9 @@ struct InvalidAstError: virtual util::Exception {}; #define astAssert_2(CONDITION, DESCRIPTION) \ assertThrowWithDefaultDescription( \ - CONDITION, \ + (CONDITION), \ ::solidity::langutil::InvalidAstError, \ - DESCRIPTION, \ + (DESCRIPTION), \ "AST assertion failed" \ ) diff --git a/libsmtutil/Exceptions.h b/libsmtutil/Exceptions.h index fd144ca72..2a32c4fcd 100644 --- a/libsmtutil/Exceptions.h +++ b/libsmtutil/Exceptions.h @@ -38,13 +38,13 @@ struct SMTLogicError: virtual util::Exception {}; #endif #define smtAssert_1(CONDITION) \ - smtAssert_2(CONDITION, "") + smtAssert_2((CONDITION), "") #define smtAssert_2(CONDITION, DESCRIPTION) \ assertThrowWithDefaultDescription( \ - CONDITION, \ + (CONDITION), \ ::solidity::smtutil::SMTLogicError, \ - DESCRIPTION, \ + (DESCRIPTION), \ "SMT assertion failed" \ ) diff --git a/libsolutil/Assertions.h b/libsolutil/Assertions.h index 81823e040..4924522d6 100644 --- a/libsolutil/Assertions.h +++ b/libsolutil/Assertions.h @@ -63,7 +63,7 @@ inline std::string stringOrDefault(std::string _string, std::string _defaultStri if (!(_condition)) \ solThrow( \ _exceptionType, \ - ::solidity::util::assertions::stringOrDefault(_description, _defaultDescription) \ + ::solidity::util::assertions::stringOrDefault((_description), (_defaultDescription)) \ ); \ } \ while (false) @@ -72,6 +72,6 @@ inline std::string stringOrDefault(std::string _string, std::string _defaultStri /// Use it as assertThrow(1 == 1, ExceptionType, "Mathematics is wrong."); /// The second parameter must be an exception class (rather than an instance). #define assertThrow(_condition, _exceptionType, _description) \ - assertThrowWithDefaultDescription(_condition, _exceptionType, _description, "Assertion failed") + assertThrowWithDefaultDescription((_condition), _exceptionType, (_description), "Assertion failed") } diff --git a/libsolutil/Exceptions.h b/libsolutil/Exceptions.h index 66b2442ef..8ac7a5fae 100644 --- a/libsolutil/Exceptions.h +++ b/libsolutil/Exceptions.h @@ -48,7 +48,7 @@ struct Exception: virtual std::exception, virtual boost::exception #define solThrow(_exceptionType, _description) \ ::boost::throw_exception( \ _exceptionType() << \ - ::solidity::util::errinfo_comment(_description) << \ + ::solidity::util::errinfo_comment((_description)) << \ ::boost::throw_function(ETH_FUNC) << \ ::boost::throw_file(__FILE__) << \ ::boost::throw_line(__LINE__) \ diff --git a/libyul/Exceptions.h b/libyul/Exceptions.h index 1ad7785e9..45c681a5d 100644 --- a/libyul/Exceptions.h +++ b/libyul/Exceptions.h @@ -63,13 +63,13 @@ struct StackTooDeepError: virtual YulException #endif #define yulAssert_1(CONDITION) \ - yulAssert_2(CONDITION, "") + yulAssert_2((CONDITION), "") #define yulAssert_2(CONDITION, DESCRIPTION) \ assertThrowWithDefaultDescription( \ - CONDITION, \ + (CONDITION), \ ::solidity::yul::YulAssertion, \ - DESCRIPTION, \ + (DESCRIPTION), \ "Yul assertion failed" \ )