-
Notifications
You must be signed in to change notification settings - Fork 285
Error handling cleanup in src/util (files starting with a-g) #2762
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
Error handling cleanup in src/util (files starting with a-g) #2762
Conversation
af53c84 to
1fa7178
Compare
|
A key problem of throwing exceptions is that they can't be used for warnings. Thus, I'd recommend retaining the message handlers in places where warnings might be needed. |
e69d31c to
700b28e
Compare
allredj
left a comment
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.
This PR failed Diffblue compatibility checks (cbmc commit: 700b28e).
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).
src/util/array_name.cpp
Outdated
| if(expr.operands().size()!=2) | ||
| throw "index takes two operands"; | ||
| DATA_INVARIANT( | ||
| expr.operands().size() == 2, "index expression has two operands"); |
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.
Use to_index_expr and let it do all the error checking and reporting.
src/util/array_name.cpp
Outdated
| { | ||
| assert(expr.operands().size()==1); | ||
| DATA_INVARIANT( | ||
| expr.operands().size() == 1, "member expression 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.
to_member_expr
700b28e to
23e9de7
Compare
23e9de7 to
b0bab14
Compare
allredj
left a comment
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.
This PR failed Diffblue compatibility checks (cbmc commit: 23e9de7).
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).
allredj
left a comment
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.
This PR failed Diffblue compatibility checks (cbmc commit: b0bab14).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/84005870
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).
allredj
left a comment
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.
Passed Diffblue compatibility checks (cbmc commit: b0bab14).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/84005870
src/util/exception_utils.h
Outdated
| std::string reason; | ||
|
|
||
| public: | ||
| system_exceptiont(const std::string &reason) : reason(reason) |
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.
Should be marked as explicit, should take reason as plain string rather than reference and should move reason.
src/util/exception_utils.h
Outdated
| public: | ||
| system_exceptiont(const std::string &reason) : reason(reason) | ||
| { | ||
| } |
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.
Should go into exception_utils.cpp
src/util/exception_utils.h
Outdated
| res += "System Exception\n"; | ||
| res += "Reason: " + reason + "\n"; | ||
| return res; | ||
| } |
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.
Should go into exception_utils.cpp
src/util/parse_options.cpp
Outdated
| std::cerr << e.what() << "\n"; | ||
| return CPROVER_EXIT_USAGE_ERROR; | ||
| } | ||
| catch(system_exceptiont &e) |
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.
We should probably add a base class like cprover_exceptiont so we don't have to do this for every single kind of exception we introduce.
b0bab14 to
e0715f3
Compare
allredj
left a comment
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.
This PR failed Diffblue compatibility checks (cbmc commit: e0715f3).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/85464121
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).
src/util/graph.h
Outdated
| while(true) | ||
| { | ||
| assert(!t.scc_stack.empty()); | ||
| INVARIANT(!t.scc_stack.empty(), ""); |
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.
Missing error message
src/util/graph.h
Outdated
| for(std::size_t i = 0; i < nodes.size(); i++) | ||
| { | ||
| INVARIANT( | ||
| reachable_idx >= reachable.size() || i <= reachable[reachable_idx], ""); |
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.
Missing message
e0715f3 to
ffc52fb
Compare
ffc52fb to
73a215c
Compare
allredj
left a comment
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.
Passed Diffblue compatibility checks (cbmc commit: 73a215c).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/85731119
| rhs=zero_initializer(symbol.type, symbol.location, ns, message_handler); | ||
| assert(rhs.is_not_nil()); | ||
| } | ||
| catch(...) |
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.
Thanks.
tautschnig
left a comment
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.
Needs another rebase and several nit-picks, plus an actual concern about static_lifetime_init.
src/util/config.cpp
Outdated
|
|
||
| if(ns.lookup(id, symbol)) | ||
| throw "failed to find "+id2string(id); | ||
| bool not_found = ns.lookup(id, symbol); |
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.
Nit pick: const
src/util/config.cpp
Outdated
|
|
||
| if(ns.lookup(id, symbol)) | ||
| throw "failed to find "+id2string(id); | ||
| bool not_found = ns.lookup(id, symbol); |
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.
Nit pick: const
src/util/config.cpp
Outdated
| if(to_integer(to_constant_expr(tmp), int_value)) | ||
| throw | ||
| "failed to convert symbol table configuration entry `"+id2string(id)+"'"; | ||
| bool error = to_integer(to_constant_expr(tmp), int_value); |
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.
Nit pick: const
src/linking/static_lifetime_init.cpp
Outdated
| { | ||
| return true; | ||
| } | ||
| namespacet ns(symbol_table); |
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.
const
|
|
||
| if(static_lifetime_init(symbol_table, symbol.location, message_handler)) | ||
| return true; | ||
| static_lifetime_init(symbol_table, symbol.location, message_handler); |
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.
This procedure still has a non-void return type, should that change?
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.
Ok, changed it to void. The remaining check in static_lifetime_init is a precondition now.
73a215c to
756c0b9
Compare
allredj
left a comment
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.
Passed Diffblue compatibility checks (cbmc commit: 756c0b9).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/85854252
No description provided.