llvmgrep 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/sh
  2. ##===- utils/llvmgrep - Counts Lines Of Code -----------------*- Script -*-===##
  3. #
  4. # The LLVM Compiler Infrastructure
  5. #
  6. # This file is distributed under the University of Illinois Open Source
  7. # 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. if test "$1" = "-topdir" ; then
  21. TOPDIR="$2"
  22. shift; shift;
  23. else
  24. TOPDIR=`llvm-config --src-root`
  25. fi
  26. if test -d "$TOPDIR" ; then
  27. cd $TOPDIR
  28. case `uname -s` in
  29. SunOS) grep_cmd="ggrep -H -n" ;;
  30. Linux|Darwin) grep_cmd="egrep -H -n" ;;
  31. *) grep_cmd="egrep -l -n" ;;
  32. esac
  33. ./utils/llvmdo -topdir "$TOPDIR" \
  34. -dirs "include lib tools utils docs examples test unittests projects cmake" $grep_cmd "$*"
  35. else
  36. echo "Can't find LLVM top directory"
  37. fi