forked from diffblue/cbmc
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use exprt::depth_iterator in rename_symbolt
- Loading branch information
1 parent
54e5b85
commit 430d402
Showing
1 changed file
with
39 additions
and
31 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -8,6 +8,7 @@ Author: Daniel Kroening, [email protected] | |
|
||
#include "rename_symbol.h" | ||
|
||
#include "expr_iterator.h" | ||
#include "std_types.h" | ||
#include "std_expr.h" | ||
|
||
|
@@ -30,45 +31,52 @@ bool rename_symbolt::rename(exprt &dest) const | |
{ | ||
bool result=true; | ||
|
||
// first look at type | ||
|
||
const exprt &const_dest(dest); | ||
if(have_to_rename(const_dest.type())) | ||
if(!rename(dest.type())) | ||
result=false; | ||
|
||
// now do expression itself | ||
|
||
if(!have_to_rename(dest)) | ||
return result; | ||
|
||
if(dest.id()==ID_symbol) | ||
for(auto it = dest.depth_begin(), end = dest.depth_end(); it != end; ++it) | ||
{ | ||
expr_mapt::const_iterator it= | ||
expr_map.find(to_symbol_expr(dest).get_identifier()); | ||
exprt * modifiable_expr = nullptr; | ||
|
||
if(it!=expr_map.end()) | ||
// first look at type | ||
if(have_to_rename(it->type())) | ||
{ | ||
to_symbol_expr(dest).set_identifier(it->second); | ||
return false; | ||
modifiable_expr = &it.mutate(); | ||
result &= rename(modifiable_expr->type()); | ||
} | ||
} | ||
|
||
Forall_operands(it, dest) | ||
if(!rename(*it)) | ||
result=false; | ||
|
||
const irept &c_sizeof_type=dest.find(ID_C_c_sizeof_type); | ||
// now do expression itself | ||
if(it->id()==ID_symbol) | ||
{ | ||
expr_mapt::const_iterator entry = | ||
expr_map.find(to_symbol_expr(*it).get_identifier()); | ||
|
||
if(c_sizeof_type.is_not_nil() && | ||
!rename(static_cast<typet&>(dest.add(ID_C_c_sizeof_type)))) | ||
result=false; | ||
if(entry != expr_map.end()) | ||
{ | ||
if(!modifiable_expr) | ||
modifiable_expr = &it.mutate(); | ||
to_symbol_expr(*modifiable_expr).set_identifier(entry->second); | ||
result = false; | ||
} | ||
} | ||
|
||
const irept &va_arg_type=dest.find(ID_C_va_arg_type); | ||
const typet &c_sizeof_type = | ||
static_cast<const typet&>(it->find(ID_C_c_sizeof_type)); | ||
if(c_sizeof_type.is_not_nil() && have_to_rename(c_sizeof_type)) | ||
{ | ||
if(!modifiable_expr) | ||
modifiable_expr = &it.mutate(); | ||
result &= | ||
rename(static_cast<typet&>(modifiable_expr->add(ID_C_c_sizeof_type))); | ||
} | ||
|
||
if(va_arg_type.is_not_nil() && | ||
!rename(static_cast<typet&>(dest.add(ID_C_va_arg_type)))) | ||
result=false; | ||
const typet &va_arg_type = | ||
static_cast<const typet&>(it->find(ID_C_va_arg_type)); | ||
if(va_arg_type.is_not_nil() && have_to_rename(va_arg_type)) | ||
{ | ||
if(!modifiable_expr) | ||
modifiable_expr = &it.mutate(); | ||
result &= | ||
rename(static_cast<typet&>(modifiable_expr->add(ID_C_va_arg_type))); | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
|