Author: d0k
Date: Sat Jan 12 15:39:06 2013
New Revision: 172330

URL: http://llvm.org/viewvc/llvm-project?rev=172330&view=rev
Log:
Speed up find-unused-diagnostics. Now runs in less than a second instead of 
more than a minute.

Modified:
    cfe/trunk/utils/find-unused-diagnostics.sh   (contents, props changed)

Modified: cfe/trunk/utils/find-unused-diagnostics.sh
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/find-unused-diagnostics.sh?rev=172330&r1=172329&r2=172330&view=diff
==============================================================================
--- cfe/trunk/utils/find-unused-diagnostics.sh (original)
+++ cfe/trunk/utils/find-unused-diagnostics.sh Sat Jan 12 15:39:06 2013
@@ -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.
+diff -u <(sort -u <<< "$ALL_DIAGS") <(sort -u <<< "$DIAGS_IN_SOURCES") | sed 
-En 's/^-([a-z_]+)/\1/p'

Propchange: cfe/trunk/utils/find-unused-diagnostics.sh
------------------------------------------------------------------------------
    svn:executable = *


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to