xref: /netbsd-src/external/apache2/llvm/dist/llvm/utils/llvmgrep (revision 7330f729ccf0bd976a06f95fad452fe774fc7fd1)
1*7330f729Sjoerg#!/bin/sh
2*7330f729Sjoerg##===- utils/llvmgrep - Counts Lines Of Code -----------------*- Script -*-===##
3*7330f729Sjoerg#
4*7330f729Sjoerg# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5*7330f729Sjoerg# See https://llvm.org/LICENSE.txt for license information.
6*7330f729Sjoerg# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7*7330f729Sjoerg#
8*7330f729Sjoerg##===----------------------------------------------------------------------===##
9*7330f729Sjoerg#
10*7330f729Sjoerg# This script searches your srcdir for an egrep style pattern. This can quickly
11*7330f729Sjoerg# help you build a list of the places you need to modify when changing a header
12*7330f729Sjoerg# or other "global" name. The only argument is the pattern you want to search
13*7330f729Sjoerg# for. It should be quoted to escape shell interpretation of the pattern's
14*7330f729Sjoerg# special characters.
15*7330f729Sjoerg#
16*7330f729Sjoerg# Note that the implementation is based on llvmdo. See that script for more
17*7330f729Sjoerg# details.
18*7330f729Sjoerg##===----------------------------------------------------------------------===##
19*7330f729Sjoerg
20*7330f729Sjoergif test "$1" = "-topdir" ; then
21*7330f729Sjoerg  TOPDIR="$2"
22*7330f729Sjoerg  shift; shift;
23*7330f729Sjoergelse
24*7330f729Sjoerg  TOPDIR=`llvm-config --src-root`
25*7330f729Sjoergfi
26*7330f729Sjoerg
27*7330f729Sjoergif test -d "$TOPDIR" ; then
28*7330f729Sjoerg  cd $TOPDIR
29*7330f729Sjoerg  case `uname -s` in
30*7330f729Sjoerg    SunOS) grep_cmd="ggrep -H -n" ;;
31*7330f729Sjoerg    Linux|Darwin) grep_cmd="egrep -H -n" ;;
32*7330f729Sjoerg    *) grep_cmd="egrep -l -n" ;;
33*7330f729Sjoerg  esac
34*7330f729Sjoerg  ./utils/llvmdo -topdir "$TOPDIR" \
35*7330f729Sjoerg    -dirs "include lib tools utils docs examples test unittests projects cmake" $grep_cmd "$*"
36*7330f729Sjoergelse
37*7330f729Sjoerg  echo "Can't find LLVM top directory"
38*7330f729Sjoergfi
39