blob: dc15da4961efcad5cd8c668056af99f1c7099ccd [file] [log] [blame]
Reid Spencer2d672082004-06-19 20:32:55 +00001#!/bin/sh
Reid Spencer181e65d2004-09-20 08:09:36 +00002##===- utils/llvmgrep - Counts Lines Of Code -----------------*- Script -*-===##
3#
4# The LLVM Compiler Infrastructure
5#
Chris Lattner30609102007-12-29 20:37:13 +00006# This file is distributed under the University of Illinois Open Source
7# License. See LICENSE.TXT for details.
Reid Spencer181e65d2004-09-20 08:09:36 +00008#
9##===----------------------------------------------------------------------===##
10#
11# This script searches your srcdir for an egrep style pattern. This can quickly
12# help you build a list of the places you need to modify when changing a header
13# or other "global" name. The only argument is the pattern you want to search
14# for. It should be quoted to escape shell interpretation of the pattern's
15# special characters.
16#
17# Note that the implementation is based on llvmdo. See that script for more
18# details.
19##===----------------------------------------------------------------------===##
20
Reid Spencer6ae928f2006-08-15 03:48:22 +000021if test "$1" = "-topdir" ; then
22 TOPDIR="$2"
23 shift; shift;
24else
25 TOPDIR=`llvm-config --src-root`
Reid Spencerca7592a2006-08-14 18:49:05 +000026fi
27
Reid Spencer2d672082004-06-19 20:32:55 +000028if test -d "$TOPDIR" ; then
29 cd $TOPDIR
Reid Spencer054defa2004-10-07 16:03:21 +000030 case `uname -s` in
31 SunOS) grep_cmd="ggrep -H -n" ;;
Eric Christopherf26475a2012-01-26 22:06:23 +000032 Linux|Darwin) grep_cmd="egrep -H -n" ;;
Reid Spencer054defa2004-10-07 16:03:21 +000033 *) grep_cmd="egrep -l -n" ;;
34 esac
Reid Spencerca7592a2006-08-14 18:49:05 +000035 ./utils/llvmdo -topdir "$TOPDIR" \
Chris Lattnere8f6e792009-08-24 03:44:02 +000036 -dirs "include lib tools utils docs examples test unittests projects cmake" $grep_cmd "$*"
Reid Spencer23a354d2004-07-07 21:19:01 +000037else
Reid Spencerca7592a2006-08-14 18:49:05 +000038 echo "Can't find LLVM top directory"
Reid Spencer2d672082004-06-19 20:32:55 +000039fi