-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
extended calculation of info for regexes #4656
Conversation
…aph with regex info
There are build warnings for the initialization order. You want this list:
To have the same order as the appearances in the declarations.
|
src/ast/seq_decl_plugin.h
Outdated
/* All bounded loops have a body that is a singleton. */ | ||
bool monadic; | ||
/* Positive Boolean combination of ranges or predicates or singleton sequences. */ | ||
bool singleton; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to be in same order during initialization
src/ast/seq_decl_plugin.cpp
Outdated
min_length = std::min(i1.min_length, i2.min_length); | ||
nullable = (i1.nullable == i2.nullable ? i1.nullable : l_undef); | ||
//TBD: whether ite is interpreted or not depends on whether the condition is interpreted and both branches are interpreted | ||
return info(false, false, false, false, i1.normalized && i2.normalized, i1.monadic && i2.monadic, i1.singleton && i2.singleton, nullable, min_length, std::max(i1.star_height, i2.star_height)); | ||
} | ||
return invalid_info; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it is possible to return invalid_info, the combiners need to be defined if one of the infos is invalid.
Currently, initialization of invalid infos leave a lot of fields uninitialized. This leads to undefined behavior.
src/ast/seq_decl_plugin.h
Outdated
/* | ||
Constructs an invalid info | ||
*/ | ||
info() : valid(false) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to assign default initialization to all fields.
You can use the syntax
lbool nullable { l_undef };
in the declarations to indicate default initializers.
src/ast/seq_decl_plugin.cpp
Outdated
case OP_RE_STAR: | ||
i1 = get_info_rec(e->get_arg(0)); | ||
return info(i1.classical, i1.classical, i1.interpreted, i1.nonbranching, i1.normalized, i1.monadic, false, l_true, 0, i1.star_height + 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems cleaner if you simply update i1, such as i1.star_height++;
Note the build failures
and regression failure (on the win64 build) |
…aph with regex info
…aration order of methods
… re-info-extension
hopefully fixed regression (forgotten return stmt) |
info opt() const; | ||
info complement() const; | ||
info concat(info & rhs, bool lhs_is_concat) const; | ||
info disj(info& rhs) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
info const& rhs ?
}; | ||
private: | ||
seq_util& u; | ||
ast_manager& m; | ||
family_id m_fid; | ||
vector<info> mutable m_infos; | ||
expr_ref_vector mutable m_info_pinned; | ||
info invalid_info; | ||
info invalid_info{ info(l_undef) }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space after info before {
/* Value is either undefined (known=l_undef) or defined and known (l_true) or defined but unknown (l_false)*/ | ||
lbool known{ l_undef }; | ||
/* No complement, no intersection, no difference, and no if-then-else is used. Reverse is allowed. */ | ||
bool classical{ false }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space between classical and {
case OP_RE_UNION: | ||
i1 = get_info_rec(e->get_arg(0)); | ||
i2 = get_info_rec(e->get_arg(1)); | ||
return info(std::min(i1.min_length, i2.min_length)); | ||
return i1.disj(i2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was for the better. If you are really into overloading, you can use operator| or operator|| instead of disj.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did these updates and also updated loop info calculation, worked on the same branch but since the PR was closed, I guess I need to open a new one for these
Added new fields to the info object and implemented their calculation rules.
In particular, this fixes some earlier issues with
min-length of compl as well as min-length of difference (that was buggy).
Also updated tracing of state_graph with regex info.
Introduced the trace tag "re_info" to trace info calculation of new regex expressions.