Skip to content

Add eq and neq operators to value_sett and related types #1544

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/pointer-analysis/value_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ class value_sett
bool offset_is_set;
bool offset_is_zero() const
{ return offset_is_set && offset.is_zero(); }

bool operator==(const objectt &other) const
{
return
offset_is_set==other.offset_is_set &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering whether clang-format's suggestions should be taken into account?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resounding shrug from me. In order of diff hunks: either, either, either, either, no, either. The "no" is clearly worse than keeping one line one condition; happy to apply any of the others you like.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, so I'll hit the "merge" button as-is.

(!offset_is_set || offset==other.offset);
}
bool operator!=(const objectt &other) const
{
return !(*this==other);
}
};

class object_map_dt
Expand Down Expand Up @@ -101,6 +112,15 @@ class value_sett

object_map_dt()=default;

bool operator==(const object_map_dt &other) const
{
return data==other.data;
}
bool operator!=(const object_map_dt &other) const
{
return !(*this==other);
}

protected:
~object_map_dt()=default;
};
Expand Down Expand Up @@ -157,6 +177,18 @@ class value_sett
suffix(_suffix)
{
}

bool operator==(const entryt &other) const
{
return
identifier==other.identifier &&
suffix==other.suffix &&
object_map==other.object_map;
}
bool operator!=(const entryt &other) const
{
return !(*this==other);
}
};

typedef std::set<exprt> expr_sett;
Expand Down