-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use conditional_cast instead of make_type
No need for a local helper that unnecessarily used `follow`.
- Loading branch information
1 parent
6f628d8
commit 3b76fc8
Showing
5 changed files
with
22 additions
and
50 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 |
---|---|---|
|
@@ -16,17 +16,8 @@ Author: Daniel Kroening, [email protected] | |
#include <util/c_types.h> | ||
#include <util/format_constant.h> | ||
#include <util/pointer_expr.h> | ||
#include <util/simplify_expr.h> | ||
#include <util/std_expr.h> | ||
|
||
const exprt printf_formattert::make_type( | ||
const exprt &src, const typet &dest) | ||
{ | ||
if(src.type()==dest) | ||
return src; | ||
return simplify_expr(typecast_exprt(src, dest), ns); | ||
} | ||
|
||
void printf_formattert::operator()( | ||
const std::string &_format, | ||
const std::list<exprt> &_operands) | ||
|
@@ -106,7 +97,7 @@ void printf_formattert::process_format(std::ostream &out) | |
if(next_operand==operands.end()) | ||
break; | ||
out << format_constant( | ||
make_type(*(next_operand++), double_type())); | ||
typecast_exprt::conditional_cast(*(next_operand++), double_type())); | ||
break; | ||
|
||
case 'f': | ||
|
@@ -115,7 +106,7 @@ void printf_formattert::process_format(std::ostream &out) | |
if(next_operand==operands.end()) | ||
break; | ||
out << format_constant( | ||
make_type(*(next_operand++), double_type())); | ||
typecast_exprt::conditional_cast(*(next_operand++), double_type())); | ||
break; | ||
|
||
case 'g': | ||
|
@@ -126,7 +117,7 @@ void printf_formattert::process_format(std::ostream &out) | |
if(next_operand==operands.end()) | ||
break; | ||
out << format_constant( | ||
make_type(*(next_operand++), double_type())); | ||
typecast_exprt::conditional_cast(*(next_operand++), double_type())); | ||
break; | ||
|
||
case 's': | ||
|
@@ -151,28 +142,28 @@ void printf_formattert::process_format(std::ostream &out) | |
if(next_operand==operands.end()) | ||
break; | ||
out << format_constant( | ||
make_type(*(next_operand++), signed_int_type())); | ||
typecast_exprt::conditional_cast(*(next_operand++), signed_int_type())); | ||
break; | ||
|
||
case 'D': | ||
if(next_operand==operands.end()) | ||
break; | ||
out << format_constant( | ||
make_type(*(next_operand++), signed_long_int_type())); | ||
out << format_constant(typecast_exprt::conditional_cast( | ||
*(next_operand++), signed_long_int_type())); | ||
break; | ||
|
||
case 'u': | ||
if(next_operand==operands.end()) | ||
break; | ||
out << format_constant( | ||
make_type(*(next_operand++), unsigned_int_type())); | ||
typecast_exprt::conditional_cast(*(next_operand++), unsigned_int_type())); | ||
break; | ||
|
||
case 'U': | ||
if(next_operand==operands.end()) | ||
break; | ||
out << format_constant( | ||
make_type(*(next_operand++), unsigned_long_int_type())); | ||
out << format_constant(typecast_exprt::conditional_cast( | ||
*(next_operand++), unsigned_long_int_type())); | ||
break; | ||
|
||
default: | ||
|
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
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
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
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