-
Notifications
You must be signed in to change notification settings - Fork 273
Improvement to c_enum_typet interface #7764
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
Improvement to c_enum_typet interface #7764
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## develop #7764 +/- ##
========================================
Coverage 78.57% 78.57%
========================================
Files 1693 1693
Lines 193306 193309 +3
========================================
+ Hits 151890 151893 +3
Misses 41416 41416
☔ View full report in Codecov by Sentry. |
705f150
to
a247ba0
Compare
a247ba0
to
7a5c6c4
Compare
Interface for c_enum_typet has limited support for management of enum members. This commit adds: - a function for exposing the member vector as a non-const reference, - a constructor that takes the underlying type and a list of members and sets the constructed type accordingly.
7a5c6c4
to
2498769
Compare
@@ -36,7 +36,8 @@ static type_symbolt make_c_enum_type_symbol(std::size_t underlying_size) | |||
const signedbv_typet underlying_type{underlying_size}; | |||
c_enum_typet enum_type{underlying_type}; | |||
|
|||
auto &members = enum_type.add(ID_body).get_sub(); | |||
auto &members = enum_type.members(); | |||
members.reserve(20); |
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 might have stored 20
in a constant instead of duplicating the same magic number in 2 places.
⛏️ Also reserve
is used for performance reasons. So maybe it is better to omit it in a unit test context in order to aid readability.
This PR improves the
c_enum_typet
interface to avoid having to directly access itssub
components to add members.To achieve this it:
members()
function returning a non-const
referencestd::vector
of members to populate the enumeration with.The PR also refactor the code where the
c_enum_typet
values are populated inc_typecheck_type
to use the newmembers
function.