diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2013-01-12 21:39:06 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2013-01-12 21:39:06 +0000 |
commit | 6590abb3844997d89363df7a1267cd6d0a7f35d0 (patch) | |
tree | 049c730dde854879cb114231812dc4a725bb531e /clang/utils/find-unused-diagnostics.sh | |
parent | e392a9f2b0c81c10002badca55b7ec6ee08612c2 (diff) | |
download | bcm5719-llvm-6590abb3844997d89363df7a1267cd6d0a7f35d0.tar.gz bcm5719-llvm-6590abb3844997d89363df7a1267cd6d0a7f35d0.zip |
Speed up find-unused-diagnostics. Now runs in less than a second instead of more than a minute.
llvm-svn: 172330
Diffstat (limited to 'clang/utils/find-unused-diagnostics.sh')
-rwxr-xr-x[-rw-r--r--] | clang/utils/find-unused-diagnostics.sh | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/clang/utils/find-unused-diagnostics.sh b/clang/utils/find-unused-diagnostics.sh index 89b7f7a700d..cd6444d1e0c 100644..100755 --- a/clang/utils/find-unused-diagnostics.sh +++ b/clang/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. +diff -u <(sort -u <<< "$ALL_DIAGS") <(sort -u <<< "$DIAGS_IN_SOURCES") | sed -En 's/^-([a-z_]+)/\1/p' |