+##===- utils/llvmdo - Counts Lines Of Code -------------------*- Script -*-===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+#
+# This script is a general purpose "apply" function for the source files in LLVM
+# It uses "find" to locate all the source files and then applies the user's
+# command to them. As such, this command is often not used by itself much but
+# the other find related tools (countloc.sh,llvmgrep,getsrcs.sh,userloc.sh) are
+# all based on this script. This script defines "what is a source file" in
+# LLVM and so should be maintained if new directories, new file extensions,
+# etc. are used in LLVM as it progresses.
+#
+# Usage:
+# llvmdo [-topdir DIR] [-dirs "DIRNAMES..."] [-code-only] PROGRAM ARGS...
+#
+# The -topdir option allows you to specify the llvm source root directly. If it
+# is not specified then it will be obtained with llvm-config which must be built
+# and in your path.
+#
+# The -dirs argument allows you to specify the set of directories that are
+# searched. The default list of directories searched is:
+# include lib tools utils runtime autoconf docs test examples projects
+# Note that you must use quotes around the list of directory names.
+#
+# The -code-only option specifies that only those files that are considered
+# "code" should be visited. HTML documentation is considered code, but things
+# like README files, etc. are not.
+#
+# Finally, you simply specify whatever program you want to run against each
+# file and the arguments to give it. The PROGRAM will be given the file name
+# as its last argument.
+##===----------------------------------------------------------------------===##
+
+if test $# -lt 1 ; then
+ echo "Usage: llvmdo [-topdir DIR] [-dirs "DIRNAMES..."] [-code-only] PROGRAM ARGS..."
+ exit 1
+fi
+
+if test "$1" = "-topdir" ; then
+ TOPDIR="$2"
+ shift; shift;
+else
+ TOPDIR=`llvm-config --src-root`
+fi
+
+if test "$1" = "-dirs" ; then
+ LLVMDO_DIRS="$2"
+ shift ; shift
+elif test -z "$LLVMDO_DIRS" ; then
+ LLVMDO_DIRS="include lib tools utils runtime autoconf docs test examples projects"
+fi
+
+if test "$1" = "-code-only" ; then
+ CODE_ONLY="set"
+ shift
+else
+ CODE_ONLY=""
+fi
+
+if test "$1" = "" ; then
+ echo "Missing program name to run"
+ exit 1
+fi
+