Skip to content

Commit 6b8583d

Browse files
authored
Merge pull request diffblue#2100 from tautschnig/string-table-cleanup
Remove unused entries from the string table
2 parents 75caefa + 6670703 commit 6b8583d

File tree

11 files changed

+64
-283
lines changed

11 files changed

+64
-283
lines changed

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ jobs:
3838
script: scripts/travis_lint.sh
3939
before_cache:
4040

41+
- &string-table-check
42+
stage: Linter + Doxygen + non-debug Ubuntu/gcc-5 test
43+
env: NAME="string-table"
44+
install:
45+
script: scripts/string_table_check.sh
46+
before_cache:
47+
4148
- stage: Linter + Doxygen + non-debug Ubuntu/gcc-5 test
4249
env: NAME="DOXYGEN-CHECK"
4350
addons:

scripts/string_table_check.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
whitelist=" \
4+
"
5+
6+
cleanup()
7+
{
8+
rm -f "$ids_file"
9+
}
10+
11+
ids_file=$(mktemp)
12+
13+
trap cleanup EXIT
14+
15+
gcc -E -P -x c src/util/irep_ids.def \
16+
-D'IREP_ID_ONE(x)=ID_ ## x' -D'IREP_ID_TWO(x,y)=ID_ ## x' > $ids_file
17+
18+
for w in $whitelist
19+
do
20+
perl -p -i -e "s/^$w\n//" $ids_file
21+
done
22+
23+
for i in $(<$ids_file)
24+
do
25+
if ! git grep -w -q -c -F $i
26+
then
27+
echo "$i is never used"
28+
exit 1
29+
fi
30+
done

src/cpp/cpp_typecheck_resolve.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -839,11 +839,11 @@ exprt cpp_typecheck_resolvet::do_builtin(
839839
<< ": " << original_scope->prefix
840840
<< messaget::eom;
841841
}
842-
else if(base_name=="size_t")
842+
else if(base_name == ID_size_t)
843843
{
844844
dest=type_exprt(size_type());
845845
}
846-
else if(base_name=="ssize_t")
846+
else if(base_name == ID_ssize_t)
847847
{
848848
dest=type_exprt(signed_size_type());
849849
}

src/goto-programs/remove_asm.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ void remove_asmt::process_instruction(
195195
{
196196
gcc_asm_function_call("__asm_"+id2string(command), code, tmp_dest);
197197
}
198-
else if(command=="sync") // Power
198+
else if(command == ID_sync) // Power
199199
{
200200
goto_programt::targett t=tmp_dest.add_instruction(OTHER);
201201
t->source_location=code.source_location();
@@ -210,7 +210,7 @@ void remove_asmt::process_instruction(
210210
t->code.set(ID_RRcumul, true);
211211
t->code.set(ID_WRcumul, true);
212212
}
213-
else if(command=="lwsync") // Power
213+
else if(command == ID_lwsync) // Power
214214
{
215215
goto_programt::targett t=tmp_dest.add_instruction(OTHER);
216216
t->source_location=code.source_location();
@@ -223,7 +223,7 @@ void remove_asmt::process_instruction(
223223
t->code.set(ID_RWcumul, true);
224224
t->code.set(ID_RRcumul, true);
225225
}
226-
else if(command=="isync") // Power
226+
else if(command == ID_isync) // Power
227227
{
228228
goto_programt::targett t=tmp_dest.add_instruction(OTHER);
229229
t->source_location=code.source_location();

src/goto-symex/slice_by_trace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ void symex_slice_by_tracet::compute_ts_back(
244244
!i->io_args.empty() &&
245245
i->io_args.front().id()=="trace_event")
246246
{
247-
irep_idt event=i->io_args.front().get("event");
247+
irep_idt event = i->io_args.front().get(ID_event);
248248

249249
if(!alphabet.empty())
250250
{

src/solvers/smt2/smt2_parser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ exprt smt2_parsert::function_application()
774774
}
775775
else if(id=="rotate_left" ||
776776
id=="rotate_right" ||
777-
id=="repeat" ||
777+
id == ID_repeat ||
778778
id=="sign_extend" ||
779779
id=="zero_extend")
780780
{
@@ -826,7 +826,7 @@ exprt smt2_parsert::function_application()
826826

827827
return typecast_exprt(op[0], unsigned_type);
828828
}
829-
else if(id=="repeat")
829+
else if(id == ID_repeat)
830830
{
831831
return nil_exprt();
832832
}

src/util/irep_ids.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ const char *irep_ids_table[]=
2727

2828
#ifdef USE_DSTRING
2929

30+
enum class idt:unsigned
31+
{
32+
#define IREP_ID_ONE(the_id) id_##the_id,
33+
#define IREP_ID_TWO(the_id, str) id_##the_id,
34+
35+
#include "irep_ids.def" // NOLINT(build/include)
36+
};
37+
3038
#define IREP_ID_ONE(the_id) \
3139
const dstringt ID_##the_id=dstringt::make_from_table_index( \
3240
static_cast<unsigned>(idt::id_##the_id));

0 commit comments

Comments
 (0)