Skip to content

Replace asserts in std_code.h with invariant macros #2767

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

Conversation

danpoe
Copy link
Contributor

@danpoe danpoe commented Aug 20, 2018

No description provided.

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.

One nitpick re: phrasing

@@ -143,7 +143,7 @@ class code_blockt:public codet
}
else if(statement==ID_label)
{
assert(last->operands().size()==1);
DATA_INVARIANT(last->operands().size()==1, "label has one operand");
Copy link
Contributor

Choose a reason for hiding this comment

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

Phrase as a "must" or "should" statement, otherwise you get a confusing crash dump like "Invariant failed: label has one operand" which suggests the label having one operand is wrong.

@danpoe danpoe force-pushed the refactor/replace-asserts-std-code branch from 07e5cba to 1c477b7 Compare August 21, 2018 09:36
assert(code.get_statement()==ID_dead && code.operands().size()==1);
PRECONDITION(code.get_statement() == ID_dead);
DATA_INVARIANT(
code.operands().size() == 1, "Dead code must have one operand");
Copy link
Member

Choose a reason for hiding this comment

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

Better dead code -> dead statement ?

code.operands().size()==1);
PRECONDITION(code.get_statement() == ID_expression);
DATA_INVARIANT(
code.operands().size() == 1, "Expression must have one operand");
Copy link
Member

Choose a reason for hiding this comment

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

expression statement?

Copy link
Collaborator

@tautschnig tautschnig left a comment

Choose a reason for hiding this comment

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

If doing such cleanup-only changes, can we please get agreement and coding-standard rules on whether the error message should be lowercase or uppercase? This is not currently consistent across the code base, the coding standard mentions lowercase. I would just like to avoid that we touch those lines of code twice for cleanup-only commits.

My request-for-changes is that the rule be put in place.

@peterschrammel
Copy link
Member

peterschrammel commented Aug 21, 2018

https://github.com/diffblue/cbmc/blob/develop/CODING_STANDARD.md: "Error messages should start with a lower case letter."

My request-for-changes is that the rule be put in place.

Thanks for raising this issue. The rule needs to be enforced.

@tautschnig
Copy link
Collaborator

I'll leave my request-for-changes in place for now, though with @peterschrammel's reminding me of the specific wording as a request for "please change all error messages to lowercase."

@danpoe danpoe force-pushed the refactor/replace-asserts-std-code branch from 1c477b7 to d1978a9 Compare August 21, 2018 15:27
@danpoe danpoe force-pushed the refactor/replace-asserts-std-code branch from d1978a9 to e5032b6 Compare September 3, 2018 12:18
@danpoe
Copy link
Contributor Author

danpoe commented Sep 3, 2018

@tautschnig I've now addressed all the comments

@tautschnig tautschnig merged commit ecb7b6b into diffblue:develop Sep 3, 2018
@danpoe danpoe deleted the refactor/replace-asserts-std-code branch June 2, 2020 17:18
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.

4 participants