Skip to content

Cleanup use of empty strings #4041

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 9 commits into from
Apr 30, 2019
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
2 changes: 1 addition & 1 deletion jbmc/src/janalyzer/janalyzer_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ int janalyzer_parse_optionst::perform_analysis(const optionst &options)

if(cmdline.isset("show-taint"))
{
taint_analysis(goto_model, taint_file, ui_message_handler, true, "");
taint_analysis(goto_model, taint_file, ui_message_handler, true);
return CPROVER_EXIT_SUCCESS;
}
else
Expand Down
5 changes: 2 additions & 3 deletions jbmc/src/java_bytecode/expr2java.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,7 @@ std::string expr2javat::convert_rec(
qualifierst &new_qualifiers = *clone;
new_qualifiers.read(src);

const std::string d=
declarator==""?declarator:(" "+declarator);
const std::string d = declarator.empty() ? declarator : (" " + declarator);

const std::string q=
new_qualifiers.as_string();
Expand Down Expand Up @@ -278,7 +277,7 @@ std::string expr2javat::convert_rec(
// so we make one up, loosely inspired by the syntax
// of lambda expressions.

std::string dest="";
std::string dest;

dest+='(';
const java_method_typet::parameterst &parameters = method_type.parameters();
Expand Down
2 changes: 1 addition & 1 deletion jbmc/src/java_bytecode/java_entry_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ main_function_resultt get_main_symbol(
irep_idt main_symbol_id = resolve_friendly_method_name(
config.main.value(), symbol_table, error_message);

if(main_symbol_id==irep_idt())
if(main_symbol_id.empty())
{
message.error()
<< "main symbol resolution failed: " << error_message << messaget::eom;
Expand Down
8 changes: 3 additions & 5 deletions jbmc/src/java_bytecode/java_object_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ class recursion_set_entryt
/// Removes erase_entry (if set) from the controlled set.
~recursion_set_entryt()
{
if(erase_entry!=irep_idt())
if(!erase_entry.empty())
recursion_set.erase(erase_entry);
}

Expand All @@ -303,10 +303,8 @@ class recursion_set_entryt
/// \return true if added to the set (and therefore owned by this object)
bool insert_entry(const irep_idt &entry)
{
INVARIANT(
erase_entry==irep_idt(),
"insert_entry should only be called once");
INVARIANT(entry!=irep_idt(), "entry should be a struct tag");
INVARIANT(erase_entry.empty(), "insert_entry should only be called once");
INVARIANT(!entry.empty(), "entry should be a struct tag");
bool ret=recursion_set.insert(entry).second;
if(ret)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static irep_idt get_tag(const typet &type)
else if(type.id() == ID_struct)
return irep_idt("java::" + id2string(to_struct_type(type).get_tag()));
else
return "";
return irep_idt();
}

/// \param type: a type
Expand Down
2 changes: 1 addition & 1 deletion jbmc/unit/java-testing-utils/require_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ require_type::require_struct_tag(const typet &type, const irep_idt &identifier)
{
REQUIRE(type.id() == ID_struct_tag);
const struct_tag_typet &result = to_struct_tag_type(type);
if(identifier != "")
if(!identifier.empty())
{
REQUIRE(result.get_identifier() == identifier);
}
Expand Down
4 changes: 2 additions & 2 deletions jbmc/unit/java_bytecode/java_types/java_type_from_string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ SCENARIO("java_type_from_string", "[core][java_types]")

GIVEN("Ljava/lang/Integer;")
{
const auto integer_type = java_type_from_string("Ljava/lang/Integer;", "");
const auto integer_type = java_type_from_string("Ljava/lang/Integer;");
REQUIRE(integer_type.has_value());
}

Expand All @@ -35,7 +35,7 @@ SCENARIO("java_type_from_string", "[core][java_types]")
GIVEN("Ljava/util/List<Ljava/lang/Integer>;")
{
const auto integer_list_type =
java_type_from_string("Ljava/util/List<Ljava/lang/Integer;>;", "");
java_type_from_string("Ljava/util/List<Ljava/lang/Integer;>;");
REQUIRE(integer_list_type.has_value());
}

Expand Down
10 changes: 5 additions & 5 deletions src/analyses/ai.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class ai_baset
const goto_functionst::goto_functiont &goto_function,
std::ostream &out) const
{
output(ns, "", goto_function.body, out);
output(ns, irep_idt(), goto_function.body, out);
}

/// Output the abstract states for the whole program as JSON
Expand All @@ -178,15 +178,15 @@ class ai_baset
const namespacet &ns,
const goto_programt &goto_program) const
{
return output_json(ns, "", goto_program);
return output_json(ns, irep_idt(), goto_program);
}

/// Output the abstract states for a single function as JSON
jsont output_json(
const namespacet &ns,
const goto_functionst::goto_functiont &goto_function) const
{
return output_json(ns, "", goto_function.body);
return output_json(ns, irep_idt(), goto_function.body);
}

/// Output the abstract states for the whole program as XML
Expand All @@ -207,15 +207,15 @@ class ai_baset
const namespacet &ns,
const goto_programt &goto_program) const
{
return output_xml(ns, "", goto_program);
return output_xml(ns, irep_idt(), goto_program);
}

/// Output the abstract states for a single function as XML
xmlt output_xml(
const namespacet &ns,
const goto_functionst::goto_functiont &goto_function) const
{
return output_xml(ns, "", goto_function.body);
return output_xml(ns, irep_idt(), goto_function.body);
}

protected:
Expand Down
2 changes: 1 addition & 1 deletion src/analyses/goto_rw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ void guarded_range_domaint::output(
out << itr->first << ":" << itr->second.first;
// we don't know what mode (language) we are in, so we rely on the default
// language to be reasonable for from_expr
out << " if " << from_expr(ns, "", itr->second.second);
out << " if " << from_expr(ns, irep_idt(), itr->second.second);
}
out << "]";
}
Expand Down
13 changes: 6 additions & 7 deletions src/analyses/invariant_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ bool inv_object_storet::get(const exprt &expr, unsigned &n)
unsigned inv_object_storet::add(const exprt &expr)
{
std::string s=build_string(expr);

assert(s!="");
CHECK_RETURN(!s.empty());

mapt::number_type n=map.number(s);

Expand Down Expand Up @@ -137,7 +136,7 @@ std::string inv_object_storet::build_string(const exprt &expr) const
// we don't know what mode (language) we are in, so we rely on the default
// language to be reasonable for from_expr
if(is_constant_address(expr))
return from_expr(ns, "", expr);
return from_expr(ns, irep_idt(), expr);

if(expr.id()==ID_member)
{
Expand Down Expand Up @@ -391,8 +390,8 @@ void invariant_sett::strengthen_rec(const exprt &expr)
throw "non-Boolean argument to strengthen()";

#if 0
std::cout << "S: " << from_expr(*ns, "", expr) << '\n';
#endif
std::cout << "S: " << from_expr(*ns, irep_idt(), expr) << '\n';
#endif

if(is_false)
{
Expand Down Expand Up @@ -594,8 +593,8 @@ tvt invariant_sett::implies_rec(const exprt &expr) const
throw "implies: non-Boolean expression";

#if 0
std::cout << "I: " << from_expr(*ns, "", expr) << '\n';
#endif
std::cout << "I: " << from_expr(*ns, irep_idt(), expr) << '\n';
#endif

if(is_false) // can't get any stronger
return tvt(true);
Expand Down
2 changes: 1 addition & 1 deletion src/analyses/local_bitvector_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ void local_bitvector_analysist::output(
}

out << "\n";
goto_function.body.output_instruction(ns, "", out, *i_it);
goto_function.body.output_instruction(ns, irep_idt(), out, *i_it);
out << "\n";

l++;
Expand Down
4 changes: 2 additions & 2 deletions src/analyses/local_may_alias.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ void local_may_aliast::output(
if(loc_info.aliases.find(j)==i)
{
assert(j<objects.size());
irep_idt identifier = "";
irep_idt identifier;
if(objects[j].id() == ID_symbol)
identifier = to_symbol_expr(objects[j]).get_identifier();
out << ' ' << from_expr(ns, identifier, objects[j]);
Expand All @@ -470,7 +470,7 @@ void local_may_aliast::output(
}

out << "\n";
goto_function.body.output_instruction(ns, "", out, *i_it);
goto_function.body.output_instruction(ns, irep_idt(), out, *i_it);
out << "\n";

l++;
Expand Down
4 changes: 2 additions & 2 deletions src/analyses/local_safe_pointers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ void local_safe_pointerst::output(
}

out << '\n';
goto_program.output_instruction(ns, "", out, *i_it);
goto_program.output_instruction(ns, irep_idt(), out, *i_it);
out << '\n';
}
}
Expand Down Expand Up @@ -258,7 +258,7 @@ void local_safe_pointerst::output_safe_dereferences(
}

out << '\n';
goto_program.output_instruction(ns, "", out, *i_it);
goto_program.output_instruction(ns, irep_idt(), out, *i_it);
out << '\n';
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/analyses/static_analysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class static_analysis_baset
const goto_programt &goto_program,
std::ostream &out) const
{
output(goto_program, "", out);
output(goto_program, irep_idt(), out);
}

virtual bool has_location(locationt l) const=0;
Expand Down
2 changes: 1 addition & 1 deletion src/ansi-c/ansi_c_language.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ bool ansi_c_languaget::preprocess(
std::ostream &outstream)
{
// stdin?
if(path=="")
if(path.empty())
return c_preprocess(instream, outstream, get_message_handler());

return c_preprocess(path, outstream, get_message_handler());
Expand Down
2 changes: 1 addition & 1 deletion src/ansi-c/ansi_c_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void ansi_c_parsert::add_declarator(
}

// global?
if(current_scope().prefix=="")
if(current_scope().prefix.empty())
ansi_c_declaration.set_is_global(true);

// abstract?
Expand Down
4 changes: 2 additions & 2 deletions src/ansi-c/c_preprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ static void error_parse_line(
if(state==2)
{
saved_error_location.set_file(file);
saved_error_location.set_function("");
saved_error_location.set_function(irep_idt());
saved_error_location.set_line(line_no);
saved_error_location.set_column("");
saved_error_location.set_column(irep_idt());
}
}

Expand Down
Loading