xref: /llvm-project-15.0.7/llvm/utils/llvmgrep (revision 3e2d463a)
1#!/bin/sh
2##===- utils/llvmgrep - Counts Lines Of Code -----------------*- Script -*-===##
3#
4#                     The LLVM Compiler Infrastructure
5#
6# This file was developed by Reid Spencer and is distributed under the
7# University of Illinois Open Source License. See LICENSE.TXT for details.
8#
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
21TOPDIR=`pwd | sed -e 's#\(.*/llvm[0-9]*\).*#\1#'`
22echo $TOPDIR
23if test -d "$TOPDIR" ; then
24  cd $TOPDIR
25  case `uname -s` in
26    SunOS) grep_cmd="ggrep -H -n" ;;
27    Linux) grep_cmd="egrep -H -n" ;;
28    *) grep_cmd="egrep -l -n" ;;
29  esac
30  ./utils/llvmdo -dirs "include lib tools utils docs examples test projects" $grep_cmd "$*"
31else
32  echo "Can't find LLVM top directory in $TOPDIR"
33fi
34