-
Notifications
You must be signed in to change notification settings - Fork 283
avoid direct access to exprt::opX #3264
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,13 +132,20 @@ static bool check_renaming(const exprt &expr) | |
if(check_renaming(expr.type())) | ||
return true; | ||
|
||
if(expr.id()==ID_address_of && | ||
expr.op0().id()==ID_symbol) | ||
return check_renaming_l1(expr.op0()); | ||
else if(expr.id()==ID_address_of && | ||
expr.op0().id()==ID_index) | ||
return check_renaming_l1(expr.op0().op0()) || | ||
check_renaming(expr.op0().op1()); | ||
if( | ||
expr.id() == ID_address_of && | ||
to_address_of_expr(expr).object().id() == ID_symbol) | ||
{ | ||
return check_renaming_l1(to_address_of_expr(expr).object()); | ||
} | ||
else if( | ||
expr.id() == ID_address_of && | ||
to_address_of_expr(expr).object().id() == ID_index) | ||
{ | ||
const auto index_expr = to_index_expr(to_address_of_expr(expr).object()); | ||
return check_renaming_l1(index_expr.array()) || | ||
check_renaming(index_expr.index()); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this part still needs further work to introduce something along the lines of:
|
||
else if(expr.id()==ID_symbol) | ||
{ | ||
if(!expr.get_bool(ID_C_SSA_symbol)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,42 +39,47 @@ static exprt simplify_json_expr( | |
{ | ||
const irep_idt &value=to_constant_expr(src).get_value(); | ||
|
||
if(value!=ID_NULL && | ||
(value!=std::string(value.size(), '0') || | ||
!config.ansi_c.NULL_is_zero) && | ||
src.operands().size()==1 && | ||
src.op0().id()!=ID_constant) | ||
// try to simplify the constant pointer | ||
return simplify_json_expr(src.op0(), ns); | ||
if( | ||
value != ID_NULL && | ||
(value != std::string(value.size(), '0') || | ||
!config.ansi_c.NULL_is_zero) && | ||
src.operands().size() == 1 && | ||
to_unary_expr(src).op().id() != ID_constant) | ||
// try to simplify the constant pointer | ||
{ | ||
return simplify_json_expr(to_unary_expr(src).op(), ns); | ||
} | ||
} | ||
} | ||
else if(src.id()==ID_address_of && | ||
src.operands().size()==1 && | ||
src.op0().id()==ID_member && | ||
id2string(to_member_expr( | ||
src.op0()).get_component_name()).find("@")!=std::string::npos) | ||
else if( | ||
src.id() == ID_address_of && | ||
to_address_of_expr(src).object().id() == ID_member && | ||
id2string( | ||
to_member_expr(to_address_of_expr(src).object()).get_component_name()) | ||
.find("@") != std::string::npos) | ||
{ | ||
// simplify expressions of the form &member_expr(object, @class_identifier) | ||
return simplify_json_expr(src.op0(), ns); | ||
return simplify_json_expr(to_address_of_expr(src).object(), ns); | ||
} | ||
else if(src.id()==ID_address_of && | ||
src.operands().size()==1 && | ||
src.op0().id()==ID_index && | ||
to_index_expr(src.op0()).index().id()==ID_constant && | ||
to_constant_expr( | ||
to_index_expr(src.op0()).index()).value_is_zero_string()) | ||
else if( | ||
src.id() == ID_address_of && | ||
to_address_of_expr(src).object().id() == ID_index && | ||
to_index_expr(to_address_of_expr(src).object()).index().id() == | ||
ID_constant && | ||
to_constant_expr(to_index_expr(to_address_of_expr(src).object()).index()) | ||
.value_is_zero_string()) | ||
{ | ||
// simplify expressions of the form &array[0] | ||
return simplify_json_expr(to_index_expr(src.op0()).array(), ns); | ||
return simplify_json_expr( | ||
to_index_expr(to_address_of_expr(src).object()).array(), ns); | ||
} | ||
else if(src.id()==ID_member && | ||
src.operands().size()==1 && | ||
id2string( | ||
to_member_expr(src).get_component_name()) | ||
.find("@")!=std::string::npos) | ||
{ | ||
// simplify expressions of the form member_expr(object, @class_identifier) | ||
return simplify_json_expr(src.op0(), ns); | ||
return simplify_json_expr(to_member_expr(src).struct_op(), ns); | ||
} | ||
|
||
return src; | ||
|
@@ -317,11 +322,15 @@ json_objectt json( | |
result["name"]=json_stringt("pointer"); | ||
result["type"]=json_stringt(type_string); | ||
exprt simpl_expr=simplify_json_expr(expr, ns); | ||
if(simpl_expr.get(ID_value)==ID_NULL || | ||
// remove typecast on NULL | ||
(simpl_expr.id()==ID_constant && simpl_expr.type().id()==ID_pointer && | ||
simpl_expr.op0().get(ID_value)==ID_NULL)) | ||
if( | ||
simpl_expr.get(ID_value) == ID_NULL || | ||
// remove typecast on NULL | ||
(simpl_expr.id() == ID_constant && | ||
simpl_expr.type().id() == ID_pointer && | ||
to_unary_expr(simpl_expr).op().get(ID_value) == ID_NULL)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add braces below. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
{ | ||
result["data"]=json_stringt(value_string); | ||
} | ||
else if(simpl_expr.id()==ID_symbol) | ||
{ | ||
const irep_idt &ptr_id=to_symbol_expr(simpl_expr).get_identifier(); | ||
|
Uh oh!
There was an error while loading. Please reload this page.