Skip to content

Commit

Permalink
Put arguments in parantheses in assert macro definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
cameel committed Apr 6, 2022
1 parent 0bb885d commit 3c5930d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
16 changes: 8 additions & 8 deletions liblangutil/Exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
)

Expand All @@ -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" \
)

Expand All @@ -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" \
)

Expand Down
6 changes: 3 additions & 3 deletions libsmtutil/Exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
)

Expand Down
4 changes: 2 additions & 2 deletions libsolutil/Assertions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")

}
2 changes: 1 addition & 1 deletion libsolutil/Exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__) \
Expand Down
6 changes: 3 additions & 3 deletions libyul/Exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
)

Expand Down

0 comments on commit 3c5930d

Please sign in to comment.