Skip to content

Commit 1a9c7d5

Browse files
committed
Remove unnecessary uses of ""
Appending "" to a string has no effect.
1 parent 4aacad2 commit 1a9c7d5

13 files changed

+22
-37
lines changed

src/ansi-c/expr2c.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,9 +510,7 @@ std::string expr2ct::convert_rec(
510510

511511
if(parameters.empty())
512512
{
513-
if(code_type.has_ellipsis())
514-
dest+=""; // empty!
515-
else
513+
if(!code_type.has_ellipsis())
516514
dest+="void"; // means 'no parameters'
517515
}
518516
else

src/cbmc/all_properties_class.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ class bmc_all_propertiest:
5858

5959
// make some poor compilers happy
6060
UNREACHABLE;
61-
return "";
6261
}
6362

6463
explicit goalt(

src/cpp/parse.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -837,9 +837,8 @@ bool Parser::rNamespaceSpec(cpp_namespace_spect &namespace_spec)
837837

838838
irep_idt name;
839839

840-
if(lex.LookAhead(0)=='{')
841-
name=""; // an anonymous namespace
842-
else
840+
// namespace might be anonymous
841+
if(lex.LookAhead(0) != '{')
843842
{
844843
if(lex.get_token(tk2)==TOK_IDENTIFIER)
845844
name=tk2.data.get(ID_C_base_name);

src/goto-instrument/dot.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,12 @@ void dott::write_dot_subgraph(
192192
std::set<goto_programt::const_targett> fres;
193193
find_next(instructions, it, tres, fres);
194194

195-
std::string tlabel="true";
196-
std::string flabel="false";
197-
if(fres.empty() || tres.empty())
195+
std::string tlabel;
196+
std::string flabel;
197+
if(!fres.empty() && !tres.empty())
198198
{
199-
tlabel="";
200-
flabel="";
199+
tlabel = "true";
200+
flabel = "false";
201201
}
202202

203203
typedef std::set<goto_programt::const_targett> t;

src/goto-programs/property_checker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ std::string property_checkert::as_string(resultt result)
2121
case property_checkert::resultt::UNKNOWN: return "UNKNOWN";
2222
}
2323

24-
return "";
24+
UNREACHABLE;
2525
}
2626

2727
property_checkert::property_checkert(

src/goto-symex/partial_order_concurrency.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,6 @@ irep_idt partial_order_concurrencyt::rw_clock_id(
133133
return id2string(id(event))+"$rclk$"+std::to_string(axiom);
134134
else
135135
UNREACHABLE;
136-
137-
return "";
138136
}
139137

140138
symbol_exprt partial_order_concurrencyt::clock(

src/pointer-analysis/value_set.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ void value_sett::output(
153153
result="<"+from_expr(ns, identifier, o)+", ";
154154

155155
if(o_it->second)
156-
result += integer2string(*o_it->second) + "";
156+
result += integer2string(*o_it->second);
157157
else
158158
result+='*';
159159

src/pointer-analysis/value_set_fi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ void value_set_fit::output(
103103
result="<"+from_expr(ns, identifier, o)+", ";
104104

105105
if(o_it->second)
106-
result += integer2string(*o_it->second) + "";
106+
result += integer2string(*o_it->second);
107107
else
108108
result+='*';
109109

src/pointer-analysis/value_set_fivr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ void value_set_fivrt::output(
144144
result+=from_expr(ns, identifier, o)+", ";
145145

146146
if(o_it->second)
147-
result += integer2string(*o_it->second) + "";
147+
result += integer2string(*o_it->second);
148148
else
149149
result+='*';
150150

src/pointer-analysis/value_set_fivrns.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ void value_set_fivrnst::output_entry(
135135
result+=from_expr(ns, identifier, o)+", ";
136136

137137
if(o_it->second)
138-
result += integer2string(*o_it->second) + "";
138+
result += integer2string(*o_it->second);
139139
else
140140
result+='*';
141141

src/solvers/smt2/smt2_conv.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,6 @@ std::string smt2_convt::type2id(const typet &type) const
815815
else
816816
{
817817
UNREACHABLE;
818-
return "";
819818
}
820819
}
821820

src/solvers/strings/string_constraint_generator_format.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ class format_specifiert
7979
class format_textt
8080
{
8181
public:
82+
format_textt() = default;
83+
8284
explicit format_textt(std::string _content) : content(_content)
8385
{
8486
}
@@ -106,15 +108,15 @@ class format_elementt
106108
TEXT
107109
} format_typet;
108110

109-
explicit format_elementt(format_typet _type) : type(_type), fstring("")
111+
explicit format_elementt(format_typet _type) : type(_type)
110112
{
111113
}
112114

113115
explicit format_elementt(std::string s) : type(TEXT), fstring(s)
114116
{
115117
}
116118

117-
explicit format_elementt(format_specifiert fs) : type(SPECIFIER), fstring("")
119+
explicit format_elementt(format_specifiert fs) : type(SPECIFIER)
118120
{
119121
fspec.push_back(fs);
120122
}
@@ -194,7 +196,7 @@ static bool check_format_string(std::string s)
194196
static format_specifiert format_specifier_of_match(std::smatch &m)
195197
{
196198
int index = m[1].str().empty() ? -1 : std::stoi(m[1].str());
197-
std::string flag = m[2].str().empty() ? "" : m[2].str();
199+
std::string flag = m[2].str();
198200
int width = m[3].str().empty() ? -1 : std::stoi(m[3].str());
199201
int precision = m[4].str().empty() ? -1 : std::stoi(m[4].str());
200202
std::string tT = m[5].str();

src/util/cmdline.cpp

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,8 @@ std::string cmdlinet::get_value(char option) const
4646
{
4747
auto i=getoptnr(option);
4848

49-
if(i.has_value())
50-
{
51-
if(options[*i].values.empty())
52-
return "";
53-
else
54-
return options[*i].values.front();
55-
}
49+
if(i.has_value() && !options[*i].values.empty())
50+
return options[*i].values.front();
5651
else
5752
return "";
5853
}
@@ -96,13 +91,8 @@ std::string cmdlinet::get_value(const char *option) const
9691
{
9792
auto i=getoptnr(option);
9893

99-
if(i.has_value())
100-
{
101-
if(options[*i].values.empty())
102-
return "";
103-
else
104-
return options[*i].values.front();
105-
}
94+
if(i.has_value() && !options[*i].values.empty())
95+
return options[*i].values.front();
10696
else
10797
return "";
10898
}

0 commit comments

Comments
 (0)