*new* check_macros: find macro precedence bugs
[smatch.git] / smatch_scripts / new_bugs.sh
blob75c38d917a9feb4ec5746c234610872f40bb9f27
1 #!/bin/bash
3 new=$1
4 old=$2
6 if [ "$old" = "" ] ; then
7 echo "usage: $0 <new file> <old file>"
8 exit 1
9 fi
12 # If the $old and $new are very similar then we can
13 # filter out a lot of bug just by doing a diff.
15 # But the line numbers change quite frequently so
16 # really we only want to see if the line numbers
17 # have changed inside the function.
18 # The 42 in this message:
19 # file.c +123 some_func(42) warn: blah blah blah
22 IFS="
24 for err in $(diff -u $old $new | grep ^+ | cut -b 2- | \
25 egrep '(warn|error):' | grep " +[1-9]") ; do
27 # we are only interested in the last chunk.
28 # "some_func(42) warn: blah blah blah"
29 last=$(echo $err | cut -d ' ' -f 3-)
31 # There are some error message which include a second
32 # line number so we crudely chop that off.
33 last=$(echo $last | sed -e 's/line .*//')
35 if ! grep -Fq "$last" $old ; then
36 echo $err
38 done