3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-06 14:13:23 +00:00

add noreturn attribute #1435

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2018-01-02 08:46:17 -08:00
parent 19e12bbc62
commit 7457fa77cb
2 changed files with 15 additions and 34 deletions

View file

@ -1492,11 +1492,8 @@ void ast_manager::compact_memory() {
unsigned capacity = m_ast_table.capacity(); unsigned capacity = m_ast_table.capacity();
if (capacity > 4*m_ast_table.size()) { if (capacity > 4*m_ast_table.size()) {
ast_table new_ast_table; ast_table new_ast_table;
ast_table::iterator it = m_ast_table.begin(); for (ast* curr : m_ast_table)
ast_table::iterator end = m_ast_table.end(); new_ast_table.insert(curr);
for (; it != end; ++it) {
new_ast_table.insert(*it);
}
m_ast_table.swap(new_ast_table); m_ast_table.swap(new_ast_table);
IF_VERBOSE(10, verbose_stream() << "(ast-table :prev-capacity " << capacity IF_VERBOSE(10, verbose_stream() << "(ast-table :prev-capacity " << capacity
<< " :capacity " << m_ast_table.capacity() << " :size " << m_ast_table.size() << ")\n";); << " :capacity " << m_ast_table.capacity() << " :size " << m_ast_table.size() << ")\n";);
@ -1510,10 +1507,7 @@ void ast_manager::compress_ids() {
ptr_vector<ast> asts; ptr_vector<ast> asts;
m_expr_id_gen.cleanup(); m_expr_id_gen.cleanup();
m_decl_id_gen.cleanup(c_first_decl_id); m_decl_id_gen.cleanup(c_first_decl_id);
ast_table::iterator it = m_ast_table.begin(); for (ast * n : m_ast_table) {
ast_table::iterator end = m_ast_table.end();
for (; it != end; ++it) {
ast * n = *it;
if (is_decl(n)) if (is_decl(n))
n->m_id = m_decl_id_gen.mk(); n->m_id = m_decl_id_gen.mk();
else else
@ -1521,13 +1515,11 @@ void ast_manager::compress_ids() {
asts.push_back(n); asts.push_back(n);
} }
m_ast_table.finalize(); m_ast_table.finalize();
ptr_vector<ast>::iterator it2 = asts.begin(); for (ast* a : asts)
ptr_vector<ast>::iterator end2 = asts.end(); m_ast_table.insert(a);
for (; it2 != end2; ++it2)
m_ast_table.insert(*it2);
} }
void ast_manager::raise_exception(char const * msg) { [[noreturn]] void ast_manager::raise_exception(char const * msg) {
throw ast_exception(msg); throw ast_exception(msg);
} }
@ -1570,20 +1562,15 @@ void ast_manager::copy_families_plugins(ast_manager const & from) {
} }
void ast_manager::set_next_expr_id(unsigned id) { void ast_manager::set_next_expr_id(unsigned id) {
while (true) { try_again:
id = m_expr_id_gen.set_next_id(id); id = m_expr_id_gen.set_next_id(id);
ast_table::iterator it = m_ast_table.begin(); for (ast * curr : m_ast_table) {
ast_table::iterator end = m_ast_table.end(); if (curr->get_id() == id) {
for (; it != end; ++it) { // id is in use, move to the next one.
ast * curr = *it; ++id;
if (curr->get_id() == id) goto try_again;
break;
} }
if (it == end) }
return;
// id is in use, move to the next one.
id++;
}
} }
unsigned ast_manager::get_node_size(ast const * n) { return ::get_node_size(n); } unsigned ast_manager::get_node_size(ast const * n) { return ::get_node_size(n); }

View file

@ -53,12 +53,6 @@ Revision History:
#pragma warning(disable : 4355) #pragma warning(disable : 4355)
#endif #endif
#ifdef __GNUC__
# define Z3_NORETURN __attribute__((noreturn))
#else
# define Z3_NORETURN
#endif
class ast; class ast;
class ast_manager; class ast_manager;
@ -1521,7 +1515,7 @@ public:
void compress_ids(); void compress_ids();
// Equivalent to throw ast_exception(msg) // Equivalent to throw ast_exception(msg)
void raise_exception(char const * msg) Z3_NORETURN; [[noreturn]] void raise_exception(char const * msg);
bool is_format_manager() const { return m_format_manager == 0; } bool is_format_manager() const { return m_format_manager == 0; }