Incorporating review feedback for GC verifier patch.
[oota-llvm.git] / utils / llvmgrep
index a1f77636c4fc518b4047c4bf1246b9bf5e18fb27..c24dc6f3ab6a59ba74b3b774ead07a1054f57980 100755 (executable)
 # details.
 ##===----------------------------------------------------------------------===##
 
-TOPDIR=`pwd | sed -e 's#\(.*/llvm\).*#\1#'`
+if test "$1" = "-topdir" ; then
+  TOPDIR="$2"
+  shift; shift;
+else
+  TOPDIR=`llvm-config --src-root`
+fi
+
 if test -d "$TOPDIR" ; then
   cd $TOPDIR
   case `uname -s` in
@@ -26,7 +32,8 @@ if test -d "$TOPDIR" ; then
     Linux) grep_cmd="egrep -H -n" ;;
     *) grep_cmd="egrep -l -n" ;;
   esac
-  ./utils/llvmdo -dirs "include lib tools utils docs examples test projects" $grep_cmd "$*"
+  ./utils/llvmdo -topdir "$TOPDIR" \
+    -dirs "include lib tools utils docs examples test projects" $grep_cmd "$*"
 else
-  echo "Can't find LLVM top directory in $TOPDIR"
+  echo "Can't find LLVM top directory"
 fi