Handle all enum values in switch/case [blocks: #2310]#2548
Handle all enum values in switch/case [blocks: #2310]#2548tautschnig merged 6 commits intodiffblue:developfrom
Conversation
|
What crazy compiler won't let you use |
42e2381 to
ca1ceb9
Compare
I'd say that's a perfectly sane compiler as far as enums are concerned: it helps you not forget about values that were added to the enum type later on, but aren't handled in |
allredj
left a comment
There was a problem hiding this comment.
Passed Diffblue compatibility checks (cbmc commit: ca1ceb9).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/78386231
|
your branch name has a |
Yes, Visual Studio does complain about cases not being handled (despite the |
smowton
left a comment
There was a problem hiding this comment.
Fair point, in that case I support the change. If you do this, consider enabling -Wswitch-enum in our GCC configs so any mistake is detected early, rather than presenting developers with an annoying stumbling block when the shorthand is only flagged on Windows.
src/ansi-c/c_typecast.cpp
Outdated
| case FIXEDBV: | ||
| case LARGE_UNSIGNED_INT: | ||
| case LARGE_SIGNED_INT: | ||
| return; // do nothing |
ca1ceb9 to
b5b3ff3
Compare
chrisr-diffblue
left a comment
There was a problem hiding this comment.
Generally approve of the change. A minor nit being a possible independent commit being included in this PR, but given the PR is one of a series of nice clean ups related to compiler warnings, I'm not going to block this PR :-)
| else if(type.id() == ID_unsignedbv) | ||
| return to_unsignedbv_type(type).largest(); | ||
| UNREACHABLE; | ||
| return 0; |
There was a problem hiding this comment.
It seems like this change (and the others in this commit) are somewhat independent of the stated purpose of this PR or are these warnings triggered by the change in switch/case statements?
There was a problem hiding this comment.
I'm afraid they are: making Visual Studio happy that all cases are covered implies that the default can be removed. Doing so makes GCC unhappy as it thinks code becomes reachable. The specific code that you highlighted above, though, is not linked to one of those default-is-gone cases, but did fit the same topic. Let me know if you'd want me to dissect it.
There was a problem hiding this comment.
Thanks for the clarification - I'm fine with this PR as it is :-)
b5b3ff3 to
b08eabb
Compare
e31bd35 to
04f3ac3
Compare
allredj
left a comment
There was a problem hiding this comment.
This PR failed Diffblue compatibility checks (cbmc commit: 04f3ac3).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/78602309
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.
Common spurious failures:
- the cbmc commit has disappeared in the mean time (e.g. in a force-push)
- the author is not in the list of contributors (e.g. first-time contributors).
|
@kroening @peterschrammel Please review commit-by-commit, where you may wish to skip the clang-format-only commit. |
allredj
left a comment
There was a problem hiding this comment.
This PR failed Diffblue compatibility checks (cbmc commit: 7b51b0c).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/103086699
Status will be re-evaluated on next push.
Common spurious failures:
-
the cbmc commit has disappeared in the mean time (e.g. in a force-push)
-
the author is not in the list of contributors (e.g. first-time contributors).
-
the compatibility was already broken by an earlier merge.
16f41ce to
0727459
Compare
allredj
left a comment
There was a problem hiding this comment.
✔️
Passed Diffblue compatibility checks (cbmc commit: 0727459).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/103501248
0727459 to
bf2df04
Compare
allredj
left a comment
There was a problem hiding this comment.
This PR failed Diffblue compatibility checks (cbmc commit: bf2df04).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/104505124
Status will be re-evaluated on next push.
Common spurious failures:
-
the cbmc commit has disappeared in the mean time (e.g. in a force-push)
-
the author is not in the list of contributors (e.g. first-time contributors).
-
the compatibility was already broken by an earlier merge.
bf2df04 to
09b2fe0
Compare
This is now consistent with the warnings that Visual Studio would generate, which warns about missing enum cases in switch/case even when a default: is present.
We should not re-indent a large number of lines of code just because some case statements were added. Silence clang-format for these instead.
There are a number of reasons why instruction types were left out of these case statements : 1. Ignoring this instruction is generally a valid overapproximation. 2. Ignoring this instruction is a valid overapproximation for this domain. 3. The instruction is assumed to not be present due to preceding passes. 4. The instruction should never appear in any valid goto program. 5. The instruction is newer than the analysis code and was forgotten. This patch tries to correctly document which of these apply.
09b2fe0 to
3a333a2
Compare
This takes us back to the behaviour prior to this series of commits, and effectively is a to-do list to be addressed. We should either handle the cases, or get rid of the instruction type.
No description provided.