Added log_assert() api

This commit is contained in:
Clifford Wolf 2013-05-24 14:38:36 +02:00
parent ccd2a93439
commit ed0e2f7a6f
3 changed files with 6 additions and 4 deletions

View File

@ -140,8 +140,7 @@ std::string AST::type2str(AstNodeType type)
X(AST_EDGE) X(AST_EDGE)
#undef X #undef X
default: default:
assert(!"Missing enum to string def in AST::type2str()."); log_abort();
abort();
} }
} }

View File

@ -24,6 +24,9 @@
#include <string> #include <string>
#include <stdlib.h> #include <stdlib.h>
#include <kernel/rtlil.h>
#include <kernel/log.h>
struct CellTypes struct CellTypes
{ {
std::set<std::string> cell_types; std::set<std::string> cell_types;
@ -225,8 +228,7 @@ struct CellTypes
if (type == "$_XOR_") if (type == "$_XOR_")
return const_xor(arg1, arg2, false, false, 1); return const_xor(arg1, arg2, false, false, 1);
assert(!"Called CellType.eval() with unsupported cell type!"); log_abort();
abort();
} }
static RTLIL::Const eval(RTLIL::Cell *cell, const RTLIL::Const &arg1, const RTLIL::Const &arg2) static RTLIL::Const eval(RTLIL::Cell *cell, const RTLIL::Const &arg1, const RTLIL::Const &arg2)

View File

@ -49,5 +49,6 @@ void log_flush();
const char *log_signal(const RTLIL::SigSpec &sig, bool autoint = true); const char *log_signal(const RTLIL::SigSpec &sig, bool autoint = true);
#define log_abort() log_error("Abort in %s:%d.\n", __FILE__, __LINE__) #define log_abort() log_error("Abort in %s:%d.\n", __FILE__, __LINE__)
#define log_assert(_assert_expr_) do { if (_assert_expr_) break; log_error("Assert `%s' failed in %s:%d.\n", #_assert_expr_, __FILE__, __LINE__); } while (0)
#endif #endif