Error handling cleanup in src/util (files starting with a-g)#2762
Error handling cleanup in src/util (files starting with a-g)#2762tautschnig merged 2 commits intodiffblue:developfrom
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.
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.
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"); |
700b28e to
23e9de7
Compare
23e9de7 to
b0bab14
Compare
allredj
left a comment
There was a problem hiding this comment.
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.
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.
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.
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.
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.
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.
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.
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(), ""); |
src/util/graph.h
Outdated
| for(std::size_t i = 0; i < nodes.size(); i++) | ||
| { | ||
| INVARIANT( | ||
| reachable_idx >= reachable.size() || i <= reachable[reachable_idx], ""); |
e0715f3 to
ffc52fb
Compare
ffc52fb to
73a215c
Compare
allredj
left a comment
There was a problem hiding this comment.
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(...) |
tautschnig
left a comment
There was a problem hiding this comment.
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); |
src/util/config.cpp
Outdated
|
|
||
| if(ns.lookup(id, symbol)) | ||
| throw "failed to find "+id2string(id); | ||
| bool not_found = ns.lookup(id, symbol); |
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); |
src/linking/static_lifetime_init.cpp
Outdated
| { | ||
| return true; | ||
| } | ||
| namespacet ns(symbol_table); |
|
|
||
| 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.
This procedure still has a non-void return type, should that change?
There was a problem hiding this comment.
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.
Passed Diffblue compatibility checks (cbmc commit: 756c0b9).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/85854252
No description provided.