| Reid Spencer | 0277fd7 | 2004-06-19 20:32:55 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| Reid Spencer | 5ef171a | 2004-09-20 08:09:36 +0000 | [diff] [blame] | 2 | ##===- utils/llvmgrep - Counts Lines Of Code -----------------*- Script -*-===## |
| 3 | # |
| Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame^] | 4 | # 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 Spencer | 5ef171a | 2004-09-20 08:09:36 +0000 | [diff] [blame] | 7 | # |
| 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 Spencer | e2bcaaa | 2006-08-15 03:48:22 +0000 | [diff] [blame] | 20 | if test "$1" = "-topdir" ; then |
| 21 | TOPDIR="$2" |
| 22 | shift; shift; |
| 23 | else |
| 24 | TOPDIR=`llvm-config --src-root` |
| Reid Spencer | 235c155 | 2006-08-14 18:49:05 +0000 | [diff] [blame] | 25 | fi |
| 26 | |
| Reid Spencer | 0277fd7 | 2004-06-19 20:32:55 +0000 | [diff] [blame] | 27 | if test -d "$TOPDIR" ; then |
| 28 | cd $TOPDIR |
| Reid Spencer | 50a425a | 2004-10-07 16:03:21 +0000 | [diff] [blame] | 29 | case `uname -s` in |
| 30 | SunOS) grep_cmd="ggrep -H -n" ;; |
| Eric Christopher | 6a6a30d | 2012-01-26 22:06:23 +0000 | [diff] [blame] | 31 | Linux|Darwin) grep_cmd="egrep -H -n" ;; |
| Reid Spencer | 50a425a | 2004-10-07 16:03:21 +0000 | [diff] [blame] | 32 | *) grep_cmd="egrep -l -n" ;; |
| 33 | esac |
| Reid Spencer | 235c155 | 2006-08-14 18:49:05 +0000 | [diff] [blame] | 34 | ./utils/llvmdo -topdir "$TOPDIR" \ |
| Chris Lattner | e849956 | 2009-08-24 03:44:02 +0000 | [diff] [blame] | 35 | -dirs "include lib tools utils docs examples test unittests projects cmake" $grep_cmd "$*" |
| Reid Spencer | 37e0ba9 | 2004-07-07 21:19:01 +0000 | [diff] [blame] | 36 | else |
| Reid Spencer | 235c155 | 2006-08-14 18:49:05 +0000 | [diff] [blame] | 37 | echo "Can't find LLVM top directory" |
| Reid Spencer | 0277fd7 | 2004-06-19 20:32:55 +0000 | [diff] [blame] | 38 | fi |