check_deref: use add_dereference_hook()
[smatch.git] / smatch_data / db / create_db.sh
blobeb18fa26b255e8246e42407fd2ba61f1d1fdd9c6
1 #!/bin/bash
3 if echo $1 | grep -q '^-p' ; then
4 PROJ=$(echo $1 | cut -d = -f 2)
5 shift
6 fi
8 info_file=$1
10 if [[ "$info_file" = "" ]] ; then
11 echo "Usage: $0 -p=<project> <file with smatch messages>"
12 exit 1
15 if [ ! -e "$info_file" ] ; then
16 echo "no such file: $info_file"
17 exit 1
20 bin_dir=$(dirname $0)
21 db_file=smatch_db.sqlite.new
23 rm -f $db_file
25 for i in ${bin_dir}/*.schema ; do
26 cat $i | sqlite3 $db_file
27 done
29 ${bin_dir}/init_constraints.pl "$PROJ" $info_file $db_file
30 ${bin_dir}/init_constraints_required.pl "$PROJ" $info_file $db_file
31 ${bin_dir}/fill_db_sql.pl "$PROJ" $info_file $db_file
32 if [ -e ${info_file}.sql ] ; then
33 ${bin_dir}/fill_db_sql.pl "$PROJ" ${info_file}.sql $db_file
35 ${bin_dir}/fill_db_caller_info.pl "$PROJ" $info_file $db_file
36 if [ -e ${info_file}.caller_info ] ; then
37 ${bin_dir}/fill_db_caller_info.pl "$PROJ" ${info_file}.caller_info $db_file
39 ${bin_dir}/build_early_index.sh $db_file
41 ${bin_dir}/fill_db_type_value.pl "$PROJ" $info_file $db_file
42 ${bin_dir}/fill_db_type_size.pl "$PROJ" $info_file $db_file
43 ${bin_dir}/copy_required_constraints.pl "$PROJ" $info_file $db_file
44 ${bin_dir}/build_late_index.sh $db_file
46 ${bin_dir}/fixup_all.sh $db_file
47 if [ "$PROJ" != "" ] ; then
48 ${bin_dir}/fixup_${PROJ}.sh $db_file
51 ${bin_dir}/copy_function_pointers.pl $db_file
52 ${bin_dir}/remove_mixed_up_pointer_params.pl $db_file
53 ${bin_dir}/delete_too_common_fn_ptr.sh $db_file
54 ${bin_dir}/mark_function_ptrs_searchable.pl $db_file
56 # delete duplicate entrees and speed things up
57 echo "delete from function_ptr where rowid not in (select min(rowid) from function_ptr group by file, function, ptr, searchable);" | sqlite3 $db_file
59 ${bin_dir}/apply_return_fixes.sh -p=${PROJ} $db_file
60 if [ "$PROJ" != "" ] ; then
61 ${bin_dir}/insert_manual_states.pl ${PROJ} $db_file
64 # test the new DB
65 if ! echo "select * from return_states where type = 0 limit 1;" | \
66 sqlite3 $db_file > /dev/null ; then
67 echo "$0 failed."
68 exit 1
71 mv $db_file smatch_db.sqlite