Skip to content

Commit 29a9ce8

Browse files
committed
Remove unnecessary uses of ""
Appending "" to a string has no effect.
1 parent 7e5b60f commit 29a9ce8

File tree

12 files changed

+22
-36
lines changed

12 files changed

+22
-36
lines changed

src/ansi-c/expr2c.cpp

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

480480
if(parameters.empty())
481481
{
482-
if(code_type.has_ellipsis())
483-
dest+=""; // empty!
484-
else
482+
if(!code_type.has_ellipsis())
485483
dest+="void"; // means 'no parameters'
486484
}
487485
else

src/cpp/parse.cpp

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

840840
irep_idt name;
841841

842-
if(lex.LookAhead(0)=='{')
843-
name=""; // an anonymous namespace
844-
else
842+
// namespace might be anonymous
843+
if(lex.LookAhead(0) != '{')
845844
{
846845
if(lex.get_token(tk2)==TOK_IDENTIFIER)
847846
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
@@ -181,7 +181,7 @@ void value_sett::output(const namespacet &ns, std::ostream &out) const
181181
result = "<" + from_expr(ns, identifier, o) + ", ";
182182

183183
if(o_it->second)
184-
result += integer2string(*o_it->second) + "";
184+
result += integer2string(*o_it->second);
185185
else
186186
result += '*';
187187

src/pointer-analysis/value_set_fi.cpp

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

104104
if(o_it->second)
105-
result += integer2string(*o_it->second) + "";
105+
result += integer2string(*o_it->second);
106106
else
107107
result+='*';
108108

src/pointer-analysis/value_set_fivr.cpp

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

145145
if(o_it->second)
146-
result += integer2string(*o_it->second) + "";
146+
result += integer2string(*o_it->second);
147147
else
148148
result+='*';
149149

src/pointer-analysis/value_set_fivrns.cpp

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

136136
if(o_it->second)
137-
result += integer2string(*o_it->second) + "";
137+
result += integer2string(*o_it->second);
138138
else
139139
result+='*';
140140

src/solvers/smt2/smt2_conv.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,6 @@ std::string smt2_convt::type2id(const typet &type) const
832832
else
833833
{
834834
UNREACHABLE;
835-
return "";
836835
}
837836
}
838837

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)