mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Use BOOST_PP_OVERLOAD() to allow invoking the assertion macros without a message
This commit is contained in:
+21
-2
@@ -21,12 +21,31 @@
|
||||
#include <libsolutil/Assertions.h>
|
||||
#include <libsolutil/Exceptions.h>
|
||||
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/facilities/empty.hpp>
|
||||
#include <boost/preprocessor/facilities/overload.hpp>
|
||||
|
||||
namespace solidity::smtutil
|
||||
{
|
||||
|
||||
struct SMTLogicError: virtual util::Exception {};
|
||||
|
||||
#define smtAssert(CONDITION, DESCRIPTION) \
|
||||
assertThrowWithDefaultDescription(CONDITION, SMTLogicError, DESCRIPTION, "SMT assertion failed")
|
||||
/// Assertion that throws an SMTLogicError containing the given description if it is not met.
|
||||
#if !BOOST_PP_VARIADICS_MSVC
|
||||
#define smtAssert(...) BOOST_PP_OVERLOAD(smtAssert_,__VA_ARGS__)(__VA_ARGS__)
|
||||
#else
|
||||
#define smtAssert(...) BOOST_PP_CAT(BOOST_PP_OVERLOAD(smtAssert_,__VA_ARGS__)(__VA_ARGS__),BOOST_PP_EMPTY())
|
||||
#endif
|
||||
|
||||
#define smtAssert_1(CONDITION) \
|
||||
smtAssert_2(CONDITION, "")
|
||||
|
||||
#define smtAssert_2(CONDITION, DESCRIPTION) \
|
||||
assertThrowWithDefaultDescription( \
|
||||
CONDITION, \
|
||||
::solidity::smtutil::SMTLogicError, \
|
||||
DESCRIPTION, \
|
||||
"SMT assertion failed" \
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user