Skip to content

Remove unused entries from the string table #2100

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 7 commits into from
Apr 26, 2018
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
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ jobs:
script: scripts/travis_lint.sh
before_cache:

- &string-table-check
stage: Linter + Doxygen + non-debug Ubuntu/gcc-5 test
env: NAME="string-table"
install:
script: scripts/string_table_check.sh
before_cache:

- stage: Linter + Doxygen + non-debug Ubuntu/gcc-5 test
env: NAME="DOXYGEN-CHECK"
addons:
Expand Down
30 changes: 30 additions & 0 deletions scripts/string_table_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

whitelist=" \
"

cleanup()
{
rm -f "$ids_file"
}

ids_file=$(mktemp)

trap cleanup EXIT

gcc -E -P -x c src/util/irep_ids.def \
-D'IREP_ID_ONE(x)=ID_ ## x' -D'IREP_ID_TWO(x,y)=ID_ ## x' > $ids_file

for w in $whitelist
do
perl -p -i -e "s/^$w\n//" $ids_file
done

for i in $(<$ids_file)
do
if ! git grep -w -q -c -F $i
then
echo "$i is never used"
exit 1
fi
done
4 changes: 2 additions & 2 deletions src/cpp/cpp_typecheck_resolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -839,11 +839,11 @@ exprt cpp_typecheck_resolvet::do_builtin(
<< ": " << original_scope->prefix
<< messaget::eom;
}
else if(base_name=="size_t")
else if(base_name == ID_size_t)
{
dest=type_exprt(size_type());
}
else if(base_name=="ssize_t")
else if(base_name == ID_ssize_t)
{
dest=type_exprt(signed_size_type());
}
Expand Down
6 changes: 3 additions & 3 deletions src/goto-programs/remove_asm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ void remove_asmt::process_instruction(
{
gcc_asm_function_call("__asm_"+id2string(command), code, tmp_dest);
}
else if(command=="sync") // Power
else if(command == ID_sync) // Power
{
goto_programt::targett t=tmp_dest.add_instruction(OTHER);
t->source_location=code.source_location();
Expand All @@ -210,7 +210,7 @@ void remove_asmt::process_instruction(
t->code.set(ID_RRcumul, true);
t->code.set(ID_WRcumul, true);
}
else if(command=="lwsync") // Power
else if(command == ID_lwsync) // Power
{
goto_programt::targett t=tmp_dest.add_instruction(OTHER);
t->source_location=code.source_location();
Expand All @@ -223,7 +223,7 @@ void remove_asmt::process_instruction(
t->code.set(ID_RWcumul, true);
t->code.set(ID_RRcumul, true);
}
else if(command=="isync") // Power
else if(command == ID_isync) // Power
{
goto_programt::targett t=tmp_dest.add_instruction(OTHER);
t->source_location=code.source_location();
Expand Down
2 changes: 1 addition & 1 deletion src/goto-symex/slice_by_trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ void symex_slice_by_tracet::compute_ts_back(
!i->io_args.empty() &&
i->io_args.front().id()=="trace_event")
{
irep_idt event=i->io_args.front().get("event");
irep_idt event = i->io_args.front().get(ID_event);

if(!alphabet.empty())
{
Expand Down
4 changes: 2 additions & 2 deletions src/solvers/smt2/smt2_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ exprt smt2_parsert::function_application()
}
else if(id=="rotate_left" ||
id=="rotate_right" ||
id=="repeat" ||
id == ID_repeat ||
id=="sign_extend" ||
id=="zero_extend")
{
Expand Down Expand Up @@ -826,7 +826,7 @@ exprt smt2_parsert::function_application()

return typecast_exprt(op[0], unsigned_type);
}
else if(id=="repeat")
else if(id == ID_repeat)
{
return nil_exprt();
}
Expand Down
8 changes: 8 additions & 0 deletions src/util/irep_ids.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ const char *irep_ids_table[]=

#ifdef USE_DSTRING

enum class idt:unsigned
{
#define IREP_ID_ONE(the_id) id_##the_id,
#define IREP_ID_TWO(the_id, str) id_##the_id,

#include "irep_ids.def" // NOLINT(build/include)
};

#define IREP_ID_ONE(the_id) \
const dstringt ID_##the_id=dstringt::make_from_table_index( \
static_cast<unsigned>(idt::id_##the_id));
Expand Down
Loading