Skip to content

Cleanup some bits of code that trip up LGTM #3136

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 6 commits into from
Oct 11, 2018

Conversation

tautschnig
Copy link
Collaborator

Issues reported by Semmle's LGTM (https://lgtm.com/projects/g/diffblue/cbmc/alerts/?mode=list).

  • Each commit message has a non-empty body, explaining why the change was made.
  • My contribution is formatted in line with CODING_STANDARD.md.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

Copy link
Contributor

@smowton smowton left a comment

Choose a reason for hiding this comment

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

LGTM's suggestions LGTM

Copy link
Collaborator

@martin-cs martin-cs left a comment

Choose a reason for hiding this comment

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

Yeah; I'm in.

j.object.find("size-symbol") != j.object.end() &&
j.object.find("end-symbol") == j.object.end() &&
j["size-symbol"].is_string()));
})));
Copy link
Collaborator

Choose a reason for hiding this comment

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

... I think there might be a few other issues with this bit of code ...

std::function<void(const key_type &k, const mapped_type &m)> f) const
{
typedef std::pair<unsigned, const baset *> stack_itemt;

std::stack<stack_itemt> stack;
stack.push({depth, &n});
stack.push({start_depth, &n});
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this really the only place it is used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This might be one for @danpoe to comment on? It was a bit of a guess that this one should be the input argument, while other uses of depth would refer to the variable declared locally.

Copy link
Contributor

Choose a reason for hiding this comment

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

The changes look good to me

@@ -100,13 +100,13 @@ std::set<exprt> full_index_set(const array_string_exprt &s)
}

/// Create the cartesian product of two sets.
template<class T, class U>
std::set<std::pair<T, U>> product(const std::set<T> ts, const std::set<U> us)
template <class X, class Y>
Copy link
Contributor

Choose a reason for hiding this comment

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

❓ What's the logic here?

Copy link
Contributor

@hannes-steffenhagen-diffblue hannes-steffenhagen-diffblue Oct 11, 2018

Choose a reason for hiding this comment

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

Template parameter types get renamed to match the name of the parameters to the function, makes sense to me. X and Y are more common for this sort of thing. Though I agree this doesn't seem to be an objective improvement. According to the commit message we have a global t somewhere though, so that's probably the reason.

(Looked it up now, apparently we have a test that used tt and t as global names - I think we should probably just fix that test...)

Copy link
Contributor

@thk123 thk123 Oct 11, 2018

Choose a reason for hiding this comment

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

The t in instantiate_not_contains.cpp should just be made static right - that would fix this? This tool is super neat though!

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, it's upset that var t and template parameter T are only distinguished by case

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

Passed Diffblue compatibility checks (cbmc commit: a02dbfd).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/87644740

@tautschnig tautschnig merged commit da12819 into diffblue:develop Oct 11, 2018
@tautschnig tautschnig deleted the lgtm-cleanup branch October 11, 2018 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants