-
Notifications
You must be signed in to change notification settings - Fork 273
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
Replace asserts in std_code.h with invariant macros #2767
Conversation
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.
One nitpick re: phrasing
src/util/std_code.h
Outdated
@@ -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"); |
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.
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.
07e5cba
to
1c477b7
Compare
src/util/std_code.h
Outdated
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"); |
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 dead code
-> dead statement
?
src/util/std_code.h
Outdated
code.operands().size()==1); | ||
PRECONDITION(code.get_statement() == ID_expression); | ||
DATA_INVARIANT( | ||
code.operands().size() == 1, "Expression must have one operand"); |
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.
expression statement?
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.
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.
https://github.com/diffblue/cbmc/blob/develop/CODING_STANDARD.md: "Error messages should start with a lower case letter."
Thanks for raising this issue. The rule needs to be enforced. |
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." |
1c477b7
to
d1978a9
Compare
d1978a9
to
e5032b6
Compare
@tautschnig I've now addressed all the comments |
No description provided.