mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 17:15:31 +00:00
fix a few compilation warnings
- remove unused variables and class fields - add support for gcc 4.5 & clang's __builtin_unreachable - fix 2 bugs related to strict aliasing - remove a few unused function parameters Signed-off-by: Nuno Lopes <t-nclaud@microsoft.com>
This commit is contained in:
parent
0673f645c9
commit
7ce88d4da9
46 changed files with 97 additions and 122 deletions
|
@ -19,6 +19,7 @@ Revision History:
|
|||
#include"bit_util.h"
|
||||
#include"util.h"
|
||||
#include"debug.h"
|
||||
#include <cstring>
|
||||
|
||||
/**
|
||||
\brief (Debugging version) Return the position of the most significant (set) bit of a
|
||||
|
@ -67,7 +68,11 @@ unsigned msb_pos(unsigned v) {
|
|||
*/
|
||||
unsigned nlz_core(unsigned x) {
|
||||
SASSERT(x != 0);
|
||||
#ifdef __GNUC__
|
||||
return __builtin_clz(x);
|
||||
#else
|
||||
return 31 - msb_pos(x);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -92,8 +97,15 @@ unsigned nlz(unsigned sz, unsigned const * data) {
|
|||
*/
|
||||
unsigned ntz_core(unsigned x) {
|
||||
SASSERT(x != 0);
|
||||
#ifdef __GNUC__
|
||||
return __builtin_ctz(x);
|
||||
#else
|
||||
float f = static_cast<float>(x & static_cast<unsigned>(-static_cast<int>(x)));
|
||||
return (*reinterpret_cast<unsigned *>(&f) >> 23) - 0x7f;
|
||||
unsigned u;
|
||||
SASSERT(sizeof(u) == sizeof(f));
|
||||
memcpy(&u, &f, sizeof(u));
|
||||
return (u >> 23) - 0x7f;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,7 +24,7 @@ Revision History:
|
|||
#include"str_hashtable.h"
|
||||
#include"z3_exception.h"
|
||||
|
||||
volatile bool g_enable_assertions = true;
|
||||
static volatile bool g_enable_assertions = true;
|
||||
|
||||
void enable_assertions(bool f) {
|
||||
g_enable_assertions = f;
|
||||
|
@ -41,7 +41,7 @@ void notify_assertion_violation(const char * fileName, int line, const char * co
|
|||
std::cerr << condition << "\n";
|
||||
}
|
||||
|
||||
str_hashtable* g_enabled_debug_tags = 0;
|
||||
static str_hashtable* g_enabled_debug_tags = 0;
|
||||
|
||||
static void init_debug_table() {
|
||||
if (!g_enabled_debug_tags) {
|
||||
|
|
|
@ -29,6 +29,10 @@ bool assertions_enabled();
|
|||
#include<crtdbg.h>
|
||||
#endif
|
||||
|
||||
#ifndef __has_builtin
|
||||
# define __has_builtin(x) 0
|
||||
#endif
|
||||
|
||||
#include"error_codes.h"
|
||||
#include"warning.h"
|
||||
|
||||
|
@ -53,7 +57,14 @@ bool is_debug_enabled(const char * tag);
|
|||
#define SASSERT(COND) DEBUG_CODE(if (assertions_enabled() && !(COND)) { notify_assertion_violation(__FILE__, __LINE__, #COND); INVOKE_DEBUGGER(); })
|
||||
#define CASSERT(TAG, COND) DEBUG_CODE(if (assertions_enabled() && is_debug_enabled(TAG) && !(COND)) { notify_assertion_violation(__FILE__, __LINE__, #COND); INVOKE_DEBUGGER(); })
|
||||
#define XASSERT(COND, EXTRA_CODE) DEBUG_CODE(if (assertions_enabled() && !(COND)) { notify_assertion_violation(__FILE__, __LINE__, #COND); { EXTRA_CODE } INVOKE_DEBUGGER(); })
|
||||
|
||||
#if (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 405)) || __has_builtin(__builtin_unreachable)
|
||||
// only available in gcc >= 4.5 and in newer versions of clang
|
||||
# define UNREACHABLE() __builtin_unreachable()
|
||||
#else
|
||||
#define UNREACHABLE() DEBUG_CODE(notify_assertion_violation(__FILE__, __LINE__, "UNREACHABLE CODE WAS REACHED."); INVOKE_DEBUGGER();)
|
||||
#endif
|
||||
|
||||
#define NOT_IMPLEMENTED_YET() { std::cerr << "NOT IMPLEMENTED YET!\n"; UNREACHABLE(); exit(ERR_NOT_IMPLEMENTED_YET); } ((void) 0)
|
||||
|
||||
#ifdef Z3DEBUG
|
||||
|
|
|
@ -22,7 +22,7 @@ Notes:
|
|||
|
||||
extern void gparams_register_modules();
|
||||
|
||||
char const * g_old_params_names[] = {
|
||||
static char const * g_old_params_names[] = {
|
||||
"arith_adaptive","arith_adaptive_assertion_threshold","arith_adaptive_gcd","arith_adaptive_propagation_threshold","arith_add_binary_bounds","arith_blands_rule_threshold","arith_branch_cut_ratio","arith_dump_lemmas","arith_eager_eq_axioms","arith_eager_gcd","arith_eq_bounds","arith_euclidean_solver","arith_expand_eqs","arith_force_simplex","arith_gcd_test","arith_ignore_int","arith_lazy_adapter","arith_lazy_pivoting","arith_max_lemma_size","arith_process_all_eqs","arith_propagate_eqs","arith_propagation_mode","arith_propagation_threshold","arith_prop_strategy","arith_random_initial_value","arith_random_lower","arith_random_seed","arith_random_upper","arith_reflect","arith_skip_big_coeffs","arith_small_lemma_size","arith_solver","arith_stronger_lemmas","array_always_prop_upward","array_canonize","array_cg","array_delay_exp_axiom","array_extensional","array_laziness","array_lazy_ieq","array_lazy_ieq_delay","array_solver","array_weak","async_commands","at_labels_cex","auto_config","bb_eager","bb_ext_gates","bb_quantifiers","bin_clauses","bit2int","bv2int_distribute","bv_blast_max_size","bv_cc","bv_enable_int2bv_propagation","bv_lazy_le","bv_max_sharing","bv_reflect","bv_solver","case_split","check_at_labels","check_proof","cnf_factor","cnf_mode","context_simplifier","dack","dack_eq","dack_factor","dack_gc","dack_gc_inv_decay","dack_threshold","default_qid","default_table","default_table_checked","delay_units","delay_units_threshold","der","display_config","display_dot_proof","display_error_for_visual_studio","display_features","display_proof","display_unsat_core","distribute_forall","dt_lazy_splits","dump_goal_as_smt","elim_and","elim_bounds","elim_nlarith_quantifiers","elim_quantifiers","elim_term_ite","ematching","engine","eq_propagation","hi_div0","ignore_bad_patterns","ignore_setparameter","instruction_max","inst_gen","interactive","internalizer_nnf","lemma_gc_factor","lemma_gc_half","lemma_gc_initial","lemma_gc_new_clause_activity","lemma_gc_new_clause_relevancy","lemma_gc_new_old_ratio","lemma_gc_old_clause_activity","lemma_gc_old_clause_relevancy","lemma_gc_strategy","lift_ite","lookahead_diseq","macro_finder","max_conflicts","max_counterexamples","mbqi","mbqi_force_template","mbqi_max_cexs","mbqi_max_cexs_incr","mbqi_max_iterations","mbqi_trace","minimize_lemmas","model","model_compact","model_completion","model_display_arg_sort","model_hide_unused_partitions","model_on_final_check","model_on_timeout","model_partial","model_v1","model_v2","model_validate","new_core2th_eq","ng_lift_ite","nl_arith","nl_arith_branching","nl_arith_gb","nl_arith_gb_eqs","nl_arith_gb_perturbate","nl_arith_gb_threshold","nl_arith_max_degree","nl_arith_rounds","nnf_factor","nnf_ignore_labels","nnf_mode","nnf_sk_hack","order","order_var_weight","order_weights","phase_selection","pi_arith","pi_arith_weight","pi_avoid_skolems","pi_block_looop_patterns","pi_max_multi_patterns","pi_non_nested_arith_weight","pi_nopat_weight","pi_pull_quantifiers","pi_use_database","pi_warnings","pp_bounded","pp_bv_literals","pp_bv_neg","pp_decimal","pp_decimal_precision","pp_fixed_indent","pp_flat_assoc","pp_max_depth","pp_max_indent","pp_max_num_lines","pp_max_ribbon","pp_max_width","pp_min_alias_size","pp_simplify_implies","pp_single_line","precedence","precedence_gen","pre_demodulator","pre_simplifier","pre_simplify_expr","profile_res_sub","progress_sampling_freq","proof_mode","propagate_booleans","propagate_values","pull_cheap_ite_trees","pull_nested_quantifiers","qi_conservative_final_check","qi_cost","qi_eager_threshold","qi_lazy_instantiation","qi_lazy_quick_checker","qi_lazy_threshold","qi_max_eager_multi_patterns","qi_max_instances","qi_max_lazy_multi_pattern_matching","qi_new_gen","qi_profile","qi_profile_freq","qi_promote_unsat","qi_quick_checker","quasi_macros","random_case_split_freq","random_initial_activity","random_seed","recent_lemma_threshold","reduce_args","refine_inj_axiom","relevancy","relevancy_lemma","rel_case_split_order","restart_adaptive","restart_agility_threshold","restart_factor","restart_initial","restart_strategy","restricted_quasi_macros","simplify_clauses","smtlib2_compliant","smtlib_category","smtlib_dump_lemmas","smtlib_logic","smtlib_source_info","smtlib_trace_path","soft_timeout","solver","spc_bs","spc_es","spc_factor_subsumption_index_opt","spc_initial_subsumption_index_opt","spc_max_subsumption_index_features","spc_min_func_freq_subsumption_index","spc_num_iterations","spc_trace","statistics","strong_context_simplifier","tick","trace","trace_file_name","type_check","user_theory_persist_axioms","user_theory_preprocess_axioms","verbose","warning","well_sorted_check","z3_solver_ll_pp","z3_solver_smt_pp", 0 };
|
||||
|
||||
bool is_old_param_name(symbol const & name) {
|
||||
|
@ -35,7 +35,7 @@ bool is_old_param_name(symbol const & name) {
|
|||
return false;
|
||||
}
|
||||
|
||||
char const * g_params_renames[] = {
|
||||
static char const * g_params_renames[] = {
|
||||
"proof_mode", "proof",
|
||||
"soft_timeout", "timeout",
|
||||
"mbqi", "smt.mbqi",
|
||||
|
|
|
@ -28,6 +28,12 @@ class hwf {
|
|||
friend class hwf_manager;
|
||||
double value;
|
||||
hwf & operator=(hwf const & other) { UNREACHABLE(); return *this; }
|
||||
uint64 get_raw() const {
|
||||
uint64 n;
|
||||
SASSERT(sizeof(n) == sizeof(value));
|
||||
memcpy(&n, &value, sizeof(value));
|
||||
return n;
|
||||
}
|
||||
|
||||
public:
|
||||
hwf() {}
|
||||
|
@ -122,16 +128,15 @@ public:
|
|||
|
||||
|
||||
bool sgn(hwf const & x) const {
|
||||
uint64 raw = *reinterpret_cast<uint64 const *>(&x.value);
|
||||
return (raw & 0x8000000000000000ull) != 0;
|
||||
return (x.get_raw() & 0x8000000000000000ull) != 0;
|
||||
}
|
||||
|
||||
const uint64 sig(hwf const & x) const {
|
||||
return *reinterpret_cast<uint64 const *>(&x.value) & 0x000FFFFFFFFFFFFFull;
|
||||
return x.get_raw() & 0x000FFFFFFFFFFFFFull;
|
||||
}
|
||||
|
||||
const int exp(hwf const & x) const {
|
||||
return ((*reinterpret_cast<uint64 const *>(&x.value) & 0x7FF0000000000000ull) >> 52) - 1023;
|
||||
return ((x.get_raw() & 0x7FF0000000000000ull) >> 52) - 1023;
|
||||
}
|
||||
|
||||
bool is_nan(hwf const & x);
|
||||
|
@ -151,7 +156,7 @@ public:
|
|||
void mk_pinf(hwf & o);
|
||||
void mk_ninf(hwf & o);
|
||||
|
||||
unsigned hash(hwf const & a) { return hash_ull(*reinterpret_cast<const unsigned long long*>(&a.value)); }
|
||||
unsigned hash(hwf const & a) { return hash_ull(a.get_raw()); }
|
||||
|
||||
inline void set_rounding_mode(mpf_rounding_mode rm);
|
||||
|
||||
|
|
|
@ -27,14 +27,14 @@ void mem_finalize();
|
|||
out_of_memory_error::out_of_memory_error():z3_error(ERR_MEMOUT) {
|
||||
}
|
||||
|
||||
volatile bool g_memory_out_of_memory = false;
|
||||
bool g_memory_initialized = false;
|
||||
long long g_memory_alloc_size = 0;
|
||||
long long g_memory_max_size = 0;
|
||||
long long g_memory_max_used_size = 0;
|
||||
long long g_memory_watermark = 0;
|
||||
bool g_exit_when_out_of_memory = false;
|
||||
char const * g_out_of_memory_msg = "ERROR: out of memory";
|
||||
static volatile bool g_memory_out_of_memory = false;
|
||||
static bool g_memory_initialized = false;
|
||||
static long long g_memory_alloc_size = 0;
|
||||
static long long g_memory_max_size = 0;
|
||||
static long long g_memory_max_used_size = 0;
|
||||
static long long g_memory_watermark = 0;
|
||||
static bool g_exit_when_out_of_memory = false;
|
||||
static char const * g_out_of_memory_msg = "ERROR: out of memory";
|
||||
|
||||
void memory::exit_when_out_of_memory(bool flag, char const * msg) {
|
||||
g_exit_when_out_of_memory = flag;
|
||||
|
|
|
@ -60,11 +60,11 @@ void myInvalidParameterHandler(
|
|||
#define END_ERR_HANDLER() {}
|
||||
#endif
|
||||
|
||||
bool g_warning_msgs = true;
|
||||
bool g_use_std_stdout = false;
|
||||
std::ostream* g_error_stream = 0;
|
||||
std::ostream* g_warning_stream = 0;
|
||||
bool g_show_error_msg_prefix = true;
|
||||
static bool g_warning_msgs = true;
|
||||
static bool g_use_std_stdout = false;
|
||||
static std::ostream* g_error_stream = 0;
|
||||
static std::ostream* g_warning_stream = 0;
|
||||
static bool g_show_error_msg_prefix = true;
|
||||
|
||||
void send_warnings_to_stdout(bool flag) {
|
||||
g_use_std_stdout = flag;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue