Skip to content

Use auto to avoid unnecessary signed/unsigned conversion #2461

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 1 commit into from
Jun 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions jbmc/src/java_bytecode/java_bytecode_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ void java_bytecode_parsert::rfields(classt &parsed_class)
field.is_public=(access_flags&ACC_PUBLIC)!=0;
field.is_protected=(access_flags&ACC_PROTECTED)!=0;
field.is_private=(access_flags&ACC_PRIVATE)!=0;
size_t flags=(field.is_public?1:0)+
const auto flags = (field.is_public ? 1 : 0) +
(field.is_protected?1:0)+
(field.is_private?1:0);
DATA_INVARIANT(flags<=1, "at most one of public, protected, private");
Expand Down Expand Up @@ -1686,7 +1686,7 @@ void java_bytecode_parsert::rmethod(classt &parsed_class)
method.base_name=pool_entry(name_index).s;
method.descriptor=id2string(pool_entry(descriptor_index).s);

size_t flags=(method.is_public?1:0)+
const auto flags = (method.is_public ? 1 : 0) +
(method.is_protected?1:0)+
(method.is_private?1:0);
DATA_INVARIANT(flags<=1, "at most one of public, protected, private");
Expand Down
3 changes: 2 additions & 1 deletion src/goto-cc/gcc_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,8 @@ int gcc_modet::doit()
gcc_version.is_at_least(7))
config.ansi_c.ts_18661_3_Floatn_types=true;

int gcc_float128_minor_version = config.ansi_c.arch == "x86_64" ? 3 : 5;
const auto gcc_float128_minor_version =
config.ansi_c.arch == "x86_64" ? 3u : 5u;

config.ansi_c.Float128_type =
gcc_version.flavor == gcc_versiont::flavort::GCC &&
Expand Down
4 changes: 2 additions & 2 deletions src/goto-programs/elf_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ elf_readert::elf_readert(std::istream &_in):in(_in)

if(elf_class==ELF32)
{
char ei_data=elf32_header.e_ident[5];
const auto ei_data = elf32_header.e_ident[5];

if(ei_data==1)
little_endian=true;
Expand Down Expand Up @@ -80,7 +80,7 @@ elf_readert::elf_readert(std::istream &_in):in(_in)
reinterpret_cast<char*>(&elf64_header),
sizeof(elf64_header));

char ei_data=elf64_header.e_ident[5];
const auto ei_data = elf64_header.e_ident[5];

if(ei_data==1)
little_endian=true;
Expand Down
2 changes: 1 addition & 1 deletion src/solvers/flattening/bv_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ literalt bv_utilst::carry(literalt a, literalt b, literalt c)
if(prop.has_set_to() && prop.cnf_handled_well())
{
// propagation possible?
unsigned const_count=
const auto const_count =
a.is_constant() + b.is_constant() + c.is_constant();

// propagation is possible if two or three inputs are constant
Expand Down