A utility to run an arbitrary program on each of the LLVM source files.
authorReid Spencer <rspencer@reidspencer.com>
Mon, 26 Jul 2004 22:52:44 +0000 (22:52 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Mon, 26 Jul 2004 22:52:44 +0000 (22:52 +0000)
This is like llvmgrep but instead of running grep, it runs the command
given by the first argument. For example, to find the top ten files with
the most lines in llvm, you could:

utils/llvmdo wc -l | sort -nb | tail

Or, to find any source files with the wrong permissions, you could:

utils/llvmdo ls -l | grep -v rw-r--r--

Hopefully, you get the idea.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15246 91177308-0d34-0410-b5e6-96231b3b80d8

utils/llvmdo [new file with mode: 0755]

diff --git a/utils/llvmdo b/utils/llvmdo
new file mode 100755 (executable)
index 0000000..b94328e
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/sh
+# This is useful because it prints out all of the source files.  Useful for
+# greps.
+PROGRAM=`which $1`
+if [ ! -x "$PROGRAM" ]; then
+  echo "Can't execute $1"
+  exit 1
+fi
+shift;
+ARGS="$*"
+TOPDIR=`pwd | sed -e 's#(.*/llvm).*#$1#'`
+if test -d "$TOPDIR" ; then
+  cd $TOPDIR
+  echo $TOPDIR
+  find docs include lib tools utils projects -type f \
+      \( -path '*/doxygen/*' -o -path '*/Burg/*' \) -prune -o \
+      -name '*.[cdhyl]*' \
+      \! -name '*~' \
+      \! -name '#*' \
+      \! -name '*.ll' \
+      \! -name '*.d' \
+      \! -name '*.dir' \
+      \! -name 'Sparc.burm.c' \
+      \! -name 'llvmAsmParser.cpp' \
+      \! -name 'llvmAsmParser.h' \
+      \! -name 'FileParser.cpp' \
+      \! -name 'FileParser.h' \
+      -exec $PROGRAM $ARGS {} \;
+else
+  echo "Can't find LLVM top directory in $TOPDIR"
+fi