Skip to content

Commit

Permalink
Implement TODO and TODO_WITH_LINK macros
Browse files Browse the repository at this point in the history
See #207
  • Loading branch information
aleasims committed Mar 13, 2024
1 parent 94f8607 commit f33e89f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions include/nil/blueprint/asserts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,18 @@

#include <iostream>
#include <cstring>
#include <string>

#define UNREACHABLE(msg) ::nil::blueprint::unreachable((msg), __FILE__, __LINE__)

#define ASSERT(expr) ::nil::blueprint::assert_check((expr), #expr, __FILE__, __LINE__)

#define ASSERT_MSG(expr, msg) ::nil::blueprint::assert_check((expr), #expr, __FILE__, __LINE__, (msg))

#define TODO(msg) ::nil::blueprint::todo((msg), __FILE__, __LINE__)

#define TODO_WITH_LINK(msg, link) ::nil::blueprint::todo_with_link((msg), (link), __FILE__, __LINE__)

namespace nil {
namespace blueprint {
[[noreturn]] void abort_process() {
Expand Down Expand Up @@ -62,6 +67,23 @@ namespace nil {
abort_process();
}
}

[[noreturn]] void todo(const char *msg, const char *filename, unsigned line) {
std::cerr << "NOT YET IMPLEMENTED at " << filename << ":" << line << std::endl;
std::cerr << '\t' << msg << std::endl;
abort_process();
}

[[noreturn]] void todo_with_link(const char *msg, const char *link, const char *filename, unsigned line) {
std::string new_msg(msg);
new_msg += "\n\tTracking issue: ";
new_msg += link;
todo(new_msg.c_str(), filename, line);
}

[[noreturn]] void todo_with_link(const std::string &msg, const std::string &link, const char *filename, unsigned line) {
todo_with_link(msg.c_str(), link.c_str(), filename, line);
}
}
}

Expand Down

0 comments on commit f33e89f

Please sign in to comment.