mirror of
https://github.com/Z3Prover/z3
synced 2026-07-03 22:06:11 +00:00
Introduce (and use) a macro for the "trailing array" idiom, so we can disable warnings for this when they're in force.
This commit is contained in:
parent
7e3aad4e17
commit
fe2b6fac24
29 changed files with 93 additions and 36 deletions
|
|
@ -19,6 +19,7 @@ Revision History:
|
|||
#pragma once
|
||||
|
||||
#include "util/small_object_allocator.h"
|
||||
#include "util/trailing_array.h"
|
||||
#include "util/id_gen.h"
|
||||
#include "util/map.h"
|
||||
#include "sat/sat_types.h"
|
||||
|
|
@ -53,7 +54,7 @@ namespace sat {
|
|||
unsigned m_inact_rounds:8;
|
||||
unsigned m_glue:8;
|
||||
unsigned m_psm:8; // transient field used during gc
|
||||
literal m_lits[0];
|
||||
TRAILING_ARRAY(literal, m_lits);
|
||||
|
||||
static size_t get_obj_size(unsigned num_lits) { return sizeof(clause) + num_lits * sizeof(literal); }
|
||||
size_t get_size() const { return get_obj_size(m_capacity); }
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ Notes:
|
|||
|
||||
|
||||
#include "util/small_object_allocator.h"
|
||||
#include "util/trailing_array.h"
|
||||
#include "sat/sat_elim_eqs.h"
|
||||
|
||||
namespace pb {
|
||||
|
|
@ -147,7 +148,7 @@ namespace sat {
|
|||
unsigned m_size; // number of non-false literals
|
||||
size_t m_obj_size; // object size (counting all literals)
|
||||
literal m_head; // head literal
|
||||
literal m_literals[0]; // list of literals, put any true literal in head.
|
||||
TRAILING_ARRAY(literal, m_literals); // list of literals, put any true literal in head.
|
||||
size_t num_lits() const {
|
||||
return (m_obj_size - sizeof(nary)) / sizeof(literal);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,13 +18,14 @@ Author:
|
|||
#pragma once
|
||||
|
||||
#include "sat/sat_types.h"
|
||||
#include "util/trailing_array.h"
|
||||
#include "sat/smt/ba_constraint.h"
|
||||
|
||||
|
||||
namespace ba {
|
||||
|
||||
class xr : public constraint {
|
||||
literal m_lits[0];
|
||||
TRAILING_ARRAY(literal, m_lits);
|
||||
public:
|
||||
static size_t get_obj_size(unsigned num_lits) { return sat::constraint_base::obj_size(sizeof(xr) + num_lits * sizeof(literal)); }
|
||||
xr(unsigned id, literal_vector const& lits);
|
||||
|
|
|
|||
|
|
@ -18,13 +18,14 @@ Author:
|
|||
#pragma once
|
||||
|
||||
#include "sat/sat_types.h"
|
||||
#include "util/trailing_array.h"
|
||||
#include "sat/smt/pb_constraint.h"
|
||||
|
||||
|
||||
namespace pb {
|
||||
|
||||
class card : public constraint {
|
||||
literal m_lits[0];
|
||||
TRAILING_ARRAY(literal, m_lits);
|
||||
public:
|
||||
static size_t get_obj_size(unsigned num_lits) { return sat::constraint_base::obj_size(sizeof(card) + num_lits * sizeof(literal)); }
|
||||
card(unsigned id, literal lit, literal_vector const& lits, unsigned k);
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ Author:
|
|||
#pragma once
|
||||
|
||||
#include "sat/sat_types.h"
|
||||
#include "util/trailing_array.h"
|
||||
#include "sat/smt/pb_card.h"
|
||||
|
||||
|
||||
|
|
@ -27,7 +28,7 @@ namespace pb {
|
|||
unsigned m_slack;
|
||||
unsigned m_num_watch;
|
||||
unsigned m_max_sum;
|
||||
wliteral m_wlits[0];
|
||||
TRAILING_ARRAY(wliteral, m_wlits);
|
||||
public:
|
||||
static size_t get_obj_size(unsigned num_lits) { return sat::constraint_base::obj_size(sizeof(pbc) + num_lits * sizeof(wliteral)); }
|
||||
pbc(unsigned id, literal lit, svector<wliteral> const& wlits, unsigned k);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ Author:
|
|||
#pragma once
|
||||
|
||||
#include "util/dlist.h"
|
||||
#include "util/trailing_array.h"
|
||||
#include "ast/ast.h"
|
||||
#include "ast/quantifier_stat.h"
|
||||
#include "ast/euf/euf_enode.h"
|
||||
|
|
@ -66,7 +67,7 @@ namespace q {
|
|||
unsigned m_max_generation;
|
||||
unsigned m_min_top_generation;
|
||||
unsigned m_max_top_generation;
|
||||
euf::enode* m_nodes[0];
|
||||
TRAILING_ARRAY(euf::enode*, m_nodes);
|
||||
|
||||
binding(clause& c, app* pat, unsigned max_generation, unsigned min_top, unsigned max_top):
|
||||
c(&c),
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ Author:
|
|||
#pragma once
|
||||
|
||||
#include "util/obj_hashtable.h"
|
||||
#include "util/trailing_array.h"
|
||||
#include "ast/ast_trail.h"
|
||||
#include "ast/rewriter/der.h"
|
||||
#include "sat/smt/sat_th.h"
|
||||
|
|
@ -35,7 +36,7 @@ namespace q {
|
|||
unsigned m_num_bindings;
|
||||
unsigned m_num_literals;
|
||||
sat::literal* m_literals;
|
||||
expr* m_bindings[0];
|
||||
TRAILING_ARRAY(expr*, m_bindings);
|
||||
|
||||
q_proof_hint(symbol const& method, unsigned g, unsigned b, unsigned l) {
|
||||
m_method = method;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ Author:
|
|||
--*/
|
||||
#pragma once
|
||||
#include "ast/ast.h"
|
||||
#include "util/trailing_array.h"
|
||||
#include "ast/ast_pp.h"
|
||||
#include "ast/ast_ll_pp.h"
|
||||
#include "sat/sat_solver.h"
|
||||
|
|
@ -31,7 +32,7 @@ namespace sat {
|
|||
|
||||
class constraint_base {
|
||||
extension* m_ex = nullptr;
|
||||
unsigned m_mem[0];
|
||||
TRAILING_ARRAY(unsigned, m_mem);
|
||||
static size_t ext_size() {
|
||||
return sizeof(((constraint_base*)nullptr)->m_ex);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue