Skip to content

Commit 5788edf

Browse files
author
Daniel Kroening
committed
use dstringt::starts_with(s)
1 parent 6b05c16 commit 5788edf

32 files changed

+87
-91
lines changed

src/analyses/goto_check.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,7 @@ void goto_checkt::pointer_primitive_check(
12151215
{
12161216
const auto &symbol_expr = to_symbol_expr(pointer);
12171217

1218-
if(has_prefix(id2string(symbol_expr.get_identifier()), CPROVER_PREFIX))
1218+
if(symbol_expr.get_identifier().starts_with(CPROVER_PREFIX))
12191219
return;
12201220
}
12211221

src/ansi-c/c_preprocess.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ bool c_preprocess_gcc_clang(
537537
{
538538
if(arch == "i386" || arch == "x86_64" || arch == "x32")
539539
argv.push_back("-m16");
540-
else if(has_prefix(id2string(arch), "mips"))
540+
else if(arch.starts_with("mips"))
541541
argv.push_back("-mips16");
542542
}
543543
else if(config.ansi_c.pointer_width == 32)
@@ -546,7 +546,7 @@ bool c_preprocess_gcc_clang(
546546
argv.push_back("-m32");
547547
else if(arch == "x32")
548548
argv.push_back("-mx32");
549-
else if(has_prefix(id2string(arch), "mips"))
549+
else if(arch.starts_with("mips"))
550550
argv.push_back("-mabi=32");
551551
else if(arch == "powerpc" || arch == "ppc64" || arch == "ppc64le")
552552
argv.push_back("-m32");
@@ -559,7 +559,7 @@ bool c_preprocess_gcc_clang(
559559
{
560560
if(arch == "i386" || arch == "x86_64" || arch == "x32")
561561
argv.push_back("-m64");
562-
else if(has_prefix(id2string(arch), "mips"))
562+
else if(arch.starts_with("mips"))
563563
argv.push_back("-mabi=64");
564564
else if(arch == "powerpc" || arch == "ppc64" || arch == "ppc64le")
565565
argv.push_back("-m64");

src/ansi-c/c_typecheck_expr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ void c_typecheck_baset::typecheck_expr_symbol(exprt &expr)
843843
// preserve location
844844
expr.add_source_location()=source_location;
845845
}
846-
else if(has_prefix(id2string(identifier), CPROVER_PREFIX "constant_infinity"))
846+
else if(identifier.starts_with(CPROVER_PREFIX "constant_infinity"))
847847
{
848848
expr=infinity_exprt(symbol.type);
849849

@@ -1832,7 +1832,7 @@ void c_typecheck_baset::typecheck_expr_side_effect(side_effect_exprt &expr)
18321832
throw 0;
18331833
}
18341834
}
1835-
else if(has_prefix(id2string(statement), "assign"))
1835+
else if(statement.starts_with("assign"))
18361836
typecheck_side_effect_assignment(expr);
18371837
else if(statement==ID_function_call)
18381838
typecheck_side_effect_function_call(

src/ansi-c/c_typecheck_initializer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ exprt c_typecheck_baset::do_initializer_rec(
221221
void c_typecheck_baset::do_initializer(symbolt &symbol)
222222
{
223223
// this one doesn't need initialization
224-
if(has_prefix(id2string(symbol.name), CPROVER_PREFIX "constant_infinity"))
224+
if(symbol.name.starts_with(CPROVER_PREFIX "constant_infinity"))
225225
return;
226226

227227
if(symbol.is_static_lifetime)

src/ansi-c/expr2c.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,7 +1604,7 @@ std::string expr2ct::convert_symbol(const exprt &src)
16041604
dest=id2string(entry->second);
16051605

16061606
#if 0
1607-
if(has_prefix(id2string(id), SYMEX_DYNAMIC_PREFIX "dynamic_object"))
1607+
if(id.starts_with(SYMEX_DYNAMIC_PREFIX "dynamic_object"))
16081608
{
16091609
if(sizeof_nesting++ == 0)
16101610
dest+=" /*"+convert(src.type());
@@ -1908,9 +1908,9 @@ std::string expr2ct::convert_constant(
19081908
{
19091909
const irep_idt &op_value = to_constant_expr(annotation).get_value();
19101910

1911-
if(op_value=="INVALID" ||
1912-
has_prefix(id2string(op_value), "INVALID-") ||
1913-
op_value=="NULL+offset")
1911+
if(
1912+
op_value == "INVALID" || op_value.starts_with("INVALID-") ||
1913+
op_value == "NULL+offset")
19141914
dest=id2string(op_value);
19151915
else
19161916
return convert_norep(src, precedence);

src/cpp/cpp_typecheck_resolve.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ exprt cpp_typecheck_resolvet::do_builtin(
809809

810810
dest=type_exprt(typet(base_name));
811811
}
812-
else if(has_prefix(id2string(base_name), "constant_infinity"))
812+
else if(base_name.starts_with("constant_infinity"))
813813
{
814814
// ok, but type missing
815815
dest=exprt(ID_infinity, size_type());

src/goto-cc/compile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ bool compilet::add_written_cprover_symbols(const symbol_tablet &symbol_table)
726726
{
727727
const irep_idt &name=pair.second.name;
728728
const typet &new_type=pair.second.type;
729-
if(!(has_prefix(id2string(name), CPROVER_PREFIX) && new_type.id()==ID_code))
729+
if(!(name.starts_with(CPROVER_PREFIX) && new_type.id() == ID_code))
730730
continue;
731731

732732
bool inserted;

src/goto-harness/recursive_initialization.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ code_blockt recursive_initializationt::build_function_pointer_constructor(
10191019
: "";
10201020
// skip referencing globals because the corresponding symbols in the symbol
10211021
// table are no longer marked as file local.
1022-
if(has_prefix(id2string(sym_to_lookup), FILE_LOCAL_PREFIX))
1022+
if(sym_to_lookup.starts_with(FILE_LOCAL_PREFIX))
10231023
{
10241024
continue;
10251025
}

src/goto-instrument/branch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void branch(
2424
Forall_goto_functions(f_it, goto_model.goto_functions)
2525
{
2626
// don't instrument our internal functions
27-
if(has_prefix(id2string(f_it->first), CPROVER_PREFIX))
27+
if(f_it->first.starts_with(CPROVER_PREFIX))
2828
continue;
2929

3030
// don't instrument the function to be called,

src/goto-instrument/count_eloc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ void print_global_state_size(const goto_modelt &goto_model)
185185
if(
186186
symbol.is_type || symbol.is_macro || symbol.type.id() == ID_code ||
187187
symbol.type.get_bool(ID_C_constant) ||
188-
has_prefix(id2string(symbol.name), CPROVER_PREFIX) ||
188+
symbol.name.starts_with(CPROVER_PREFIX) ||
189189
(has_initialize && initialized.find(symbol.name) == initialized.end()))
190190
{
191191
continue;

0 commit comments

Comments
 (0)