-
Notifications
You must be signed in to change notification settings - Fork 274
Cleanup of asserts and throws under the goto-symex directory #2902
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
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,10 +14,11 @@ Author: Daniel Kroening, [email protected] | |
#include <cstdlib> | ||
#include <iostream> | ||
|
||
#include <util/invariant.h> | ||
#include <util/base_exceptions.h> | ||
#include <util/std_expr.h> | ||
#include <util/exception_utils.h> | ||
#include <util/invariant.h> | ||
#include <util/prefix.h> | ||
#include <util/std_expr.h> | ||
|
||
#include <analyses/dirty.h> | ||
|
||
|
@@ -51,8 +52,7 @@ void goto_symex_statet::level0t::operator()( | |
|
||
const symbolt *s; | ||
const bool found_l0 = !ns.lookup(obj_identifier, s); | ||
DATA_INVARIANT( | ||
found_l0, "level0: failed to find " + id2string(obj_identifier)); | ||
INVARIANT(found_l0, "level0: failed to find " + id2string(obj_identifier)); | ||
|
||
// don't rename shared variables or functions | ||
if(s->type.id()==ID_code || | ||
|
@@ -187,10 +187,7 @@ bool goto_symex_statet::constant_propagation_reference(const exprt &expr) const | |
} | ||
else if(expr.id()==ID_member) | ||
{ | ||
if(expr.operands().size()!=1) | ||
throw "member expects one operand"; | ||
|
||
return constant_propagation_reference(expr.op0()); | ||
return constant_propagation_reference(to_member_expr(expr).compound()); | ||
} | ||
else if(expr.id()==ID_string_constant) | ||
return true; | ||
|
@@ -345,7 +342,8 @@ void goto_symex_statet::assignment( | |
|
||
// see #305 on GitHub for a simple example and possible discussion | ||
if(is_shared && lhs.type().id() == ID_pointer && !allow_pointer_unsoundness) | ||
throw "pointer handling for concurrency is unsound"; | ||
throw unsupported_operation_exceptiont( | ||
"pointer handling for concurrency is unsound"); | ||
|
||
// for value propagation -- the RHS is L2 | ||
|
||
|
@@ -495,13 +493,9 @@ void goto_symex_statet::rename( | |
} | ||
else if(expr.id()==ID_address_of) | ||
{ | ||
DATA_INVARIANT( | ||
expr.operands().size() == 1, "address_of should have a single operand"); | ||
rename_address(expr.op0(), ns, level); | ||
DATA_INVARIANT( | ||
expr.type().id() == ID_pointer, | ||
"type of address_of should be ID_pointer"); | ||
expr.type().subtype()=expr.op0().type(); | ||
auto &address_of_expr = to_address_of_expr(expr); | ||
rename_address(address_of_expr.object(), ns, level); | ||
expr.type().subtype() = address_of_expr.object().type(); | ||
} | ||
else | ||
{ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ Author: Daniel Kroening, [email protected] | |
#include <langapi/language_util.h> | ||
#include <langapi/mode.h> | ||
|
||
#include <util/exception_utils.h> | ||
#include <util/json.h> | ||
#include <util/json_expr.h> | ||
#include <util/ui_message.h> | ||
|
@@ -165,7 +166,8 @@ void show_vcc( | |
{ | ||
of.open(filename); | ||
if(!of) | ||
throw "failed to open file " + filename; | ||
throw invalid_user_input_exceptiont( | ||
"invalid file to read trace from: " + filename, "--outfile"); | ||
} | ||
|
||
std::ostream &out = have_file ? of : std::cout; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,12 +16,13 @@ Author: Daniel Kroening, [email protected] | |
#include <fstream> | ||
#include <iostream> | ||
|
||
#include <util/string2int.h> | ||
#include <util/simplify_expr.h> | ||
#include <util/arith_tools.h> | ||
#include <util/std_expr.h> | ||
#include <util/guard.h> | ||
#include <util/exception_utils.h> | ||
#include <util/format_expr.h> | ||
#include <util/guard.h> | ||
#include <util/simplify_expr.h> | ||
#include <util/std_expr.h> | ||
#include <util/string2int.h> | ||
|
||
void symex_slice_by_tracet::slice_by_trace( | ||
std::string trace_files, | ||
|
@@ -79,6 +80,11 @@ void symex_slice_by_tracet::slice_by_trace( | |
{ | ||
exprt g_copy(*i); | ||
|
||
DATA_INVARIANT( | ||
g_copy.id() == ID_symbol || g_copy.id() == ID_not || | ||
g_copy.id() == ID_and || g_copy.id() == ID_constant, | ||
"guards should only be and, symbol, constant, or `not'"); | ||
|
||
if(g_copy.id()==ID_symbol || g_copy.id() == ID_not) | ||
{ | ||
g_copy.make_not(); | ||
|
@@ -92,10 +98,6 @@ void symex_slice_by_tracet::slice_by_trace( | |
simplify(copy_last, ns); | ||
implications.insert(copy_last); | ||
} | ||
else if(!(g_copy.id()==ID_constant)) | ||
{ | ||
throw "guards should only be and, symbol, constant, or `not'"; | ||
} | ||
} | ||
|
||
slice_SSA_steps(equation, implications); // Slice based on implications | ||
|
@@ -122,7 +124,8 @@ void symex_slice_by_tracet::read_trace(std::string filename) | |
std::cout << "Reading trace from file " << filename << '\n'; | ||
std::ifstream file(filename); | ||
if(file.fail()) | ||
throw "failed to read from trace file"; | ||
throw invalid_user_input_exceptiont( | ||
"invalid file to read trace from: " + filename, ""); | ||
|
||
// In case not the first trace read | ||
alphabet.clear(); | ||
|
@@ -219,9 +222,10 @@ void symex_slice_by_tracet::parse_events(std::string read_line) | |
const std::string::size_type vnext=read_line.find(",", vidx); | ||
std::string event=read_line.substr(vidx, vnext - vidx); | ||
eis.insert(event); | ||
if((!alphabet.empty()) && | ||
((alphabet.count(event)!=0)!=alphabet_parity)) | ||
throw "trace uses symbol not in alphabet: "+event; | ||
PRECONDITION(!alphabet.empty()); | ||
INVARIANT( | ||
(alphabet.count(event) != 0) == alphabet_parity, | ||
"trace uses symbol not in alphabet: " + event); | ||
if(vnext==std::string::npos) | ||
break; | ||
vidx=vnext; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I believe this should be true by design.
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.
Still, isn't it a good idea to leave it there, even if only for documentation purposes?
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.
Not a big deal, but I think if we were to go down that route we'd have, e.g., any use of an
index_exprt
prefixed byexpr.id() == ID_index
.