summaryrefslogtreecommitdiffstats
path: root/utils/find-unused-diagnostics.sh
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2013-04-08 18:45:10 +0000
committerdim <dim@FreeBSD.org>2013-04-08 18:45:10 +0000
commitc72c57c9e9b69944e3e009cd5e209634839581d3 (patch)
tree4fc2f184c499d106f29a386c452b49e5197bf63d /utils/find-unused-diagnostics.sh
parent5b20025c30d23d521e12c1f33ec8fa6b821952cd (diff)
downloadFreeBSD-src-c72c57c9e9b69944e3e009cd5e209634839581d3.zip
FreeBSD-src-c72c57c9e9b69944e3e009cd5e209634839581d3.tar.gz
Vendor import of clang trunk r178860:
http://llvm.org/svn/llvm-project/cfe/trunk@178860
Diffstat (limited to 'utils/find-unused-diagnostics.sh')
-rw-r--r--utils/find-unused-diagnostics.sh18
1 files changed, 7 insertions, 11 deletions
diff --git a/utils/find-unused-diagnostics.sh b/utils/find-unused-diagnostics.sh
index 89b7f7a..c7fa01a 100644
--- a/utils/find-unused-diagnostics.sh
+++ b/utils/find-unused-diagnostics.sh
@@ -4,16 +4,12 @@
# in Diagnostic*.td files but not used in sources.
#
-ALL_DIAGS=$(mktemp)
-ALL_SOURCES=$(mktemp)
+# Gather all diagnostic identifiers from the .td files.
+ALL_DIAGS=$(grep -E --only-matching --no-filename '(err_|warn_|ext_|note_)[a-z_]+' ./include/clang/Basic/Diagnostic*.td)
-grep -E --only-matching --no-filename '(err_|warn_|ext_|note_)[a-z_]+ ' ./include/clang/Basic/Diagnostic*.td > $ALL_DIAGS
-find lib include tools -name \*.cpp -or -name \*.h > $ALL_SOURCES
-for DIAG in $(cat $ALL_DIAGS); do
- if ! grep -r $DIAG $(cat $ALL_SOURCES) > /dev/null; then
- echo $DIAG
- fi;
-done
-
-rm $ALL_DIAGS $ALL_SOURCES
+# Now look for all potential identifiers in the source files.
+ALL_SOURCES=$(find lib include tools -name \*.cpp -or -name \*.h)
+DIAGS_IN_SOURCES=$(grep -E --only-matching --no-filename '(err_|warn_|ext_|note_)[a-z_]+' $ALL_SOURCES)
+# Print all diags that occur in the .td files but not in the source.
+comm -23 <(sort -u <<< "$ALL_DIAGS") <(sort -u <<< "$DIAGS_IN_SOURCES")
OpenPOWER on IntegriCloud