Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / bin / find-unused-typedefs.sh
blobbc4378533efa38eb64225d53e6d5d626f51d654e
2 # This is a pretty brute-force approach. It takes several hours to run on a top-spec MacbookAir.
3 # It also produces some false positives, so it requires careful examination and testing of the results.
5 # Algorithm Summary:
6 # First we find all #defines,
7 # then we search for each of them in turn,
8 # and if we find only one instance of a #define, we print it out.
10 # Algorithm Detail:
11 # (1) find #defines, excluding the externals folder
12 # (2) extract just the constant name from the search results
13 # (3) trim blank lines
14 # (4) sort the results, mostly so I have an idea how far along the process is
15 # (5) for each result:
16 # (6) grep for the constant
17 # (7) use awk to check if only one match for a given constant was found
18 # (8) if so, generate a sed command to remove the #define
20 bin/find-unused-typedefs.py \
21 | sort -u \
22 | xargs -Ixxx -n 1 -P 8 sh -c \
23 '( git grep -w xxx | awk -f bin/find-unused-defines.awk -v p1=xxx ) && echo xxx 1>&2'