blob: 28b2f95f979800aa6c127ded4da6bd160194b750 [file] [log] [blame]
Reid Spencer0277fd72004-06-19 20:32:55 +00001#!/bin/sh
Reid Spencer5ef171a2004-09-20 08:09:36 +00002##===- utils/llvmgrep - Counts Lines Of Code -----------------*- Script -*-===##
3#
Chandler Carruth2946cd72019-01-19 08:50:56 +00004# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5# See https://llvm.org/LICENSE.txt for license information.
6# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Reid Spencer5ef171a2004-09-20 08:09:36 +00007#
8##===----------------------------------------------------------------------===##
9#
10# This script searches your srcdir for an egrep style pattern. This can quickly
11# help you build a list of the places you need to modify when changing a header
12# or other "global" name. The only argument is the pattern you want to search
13# for. It should be quoted to escape shell interpretation of the pattern's
14# special characters.
15#
16# Note that the implementation is based on llvmdo. See that script for more
17# details.
18##===----------------------------------------------------------------------===##
19
Reid Spencere2bcaaa2006-08-15 03:48:22 +000020if test "$1" = "-topdir" ; then
21 TOPDIR="$2"
22 shift; shift;
23else
24 TOPDIR=`llvm-config --src-root`
Reid Spencer235c1552006-08-14 18:49:05 +000025fi
26
Reid Spencer0277fd72004-06-19 20:32:55 +000027if test -d "$TOPDIR" ; then
28 cd $TOPDIR
Reid Spencer50a425a2004-10-07 16:03:21 +000029 case `uname -s` in
30 SunOS) grep_cmd="ggrep -H -n" ;;
Eric Christopher6a6a30d2012-01-26 22:06:23 +000031 Linux|Darwin) grep_cmd="egrep -H -n" ;;
Reid Spencer50a425a2004-10-07 16:03:21 +000032 *) grep_cmd="egrep -l -n" ;;
33 esac
Reid Spencer235c1552006-08-14 18:49:05 +000034 ./utils/llvmdo -topdir "$TOPDIR" \
Chris Lattnere8499562009-08-24 03:44:02 +000035 -dirs "include lib tools utils docs examples test unittests projects cmake" $grep_cmd "$*"
Reid Spencer37e0ba92004-07-07 21:19:01 +000036else
Reid Spencer235c1552006-08-14 18:49:05 +000037 echo "Can't find LLVM top directory"
Reid Spencer0277fd72004-06-19 20:32:55 +000038fi