Home | History | Annotate | Download | only in scripts
      1 #!/bin/bash
      2 
      3 set -e
      4 
      5 SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
      6 
      7 # Guess path to LLVM_CHECKOUT if not provided
      8 if [ "${LLVM_CHECKOUT}" == "" ]; then
      9   LLVM_CHECKOUT="${SCRIPT_DIR}/../../../../../"
     10   echo "LLVM Checkout: ${LLVM_CHECKOUT}"
     11 fi
     12 
     13 # Cpplint setup
     14 cd ${SCRIPT_DIR}
     15 if [ ! -d cpplint ]; then
     16   svn co http://google-styleguide.googlecode.com/svn/trunk/cpplint cpplint
     17 else
     18   (cd cpplint && svn up)
     19 fi
     20 CPPLINT=${SCRIPT_DIR}/cpplint/cpplint.py
     21 
     22 # Filters
     23 # TODO: remove some of these filters
     24 COMMON_LINT_FILTER=-build/include,-build/header_guard,-legal/copyright,-whitespace/comments,-readability/casting,\
     25 -build/namespaces
     26 ASAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER},-runtime/int
     27 ASAN_TEST_LINT_FILTER=${COMMON_LINT_FILTER},-runtime/sizeof,-runtime/int,-runtime/printf
     28 ASAN_LIT_TEST_LINT_FILTER=${ASAN_TEST_LINT_FILTER},-whitespace/line_length
     29 TSAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER}
     30 TSAN_TEST_LINT_FILTER=${TSAN_RTL_LINT_FILTER},-runtime/threadsafe_fn,-runtime/int
     31 TSAN_LIT_TEST_LINT_FILTER=${TSAN_TEST_LINT_FILTER},-whitespace/line_length
     32 MSAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER}
     33 LSAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER}
     34 LSAN_LIT_TEST_LINT_FILTER=${LSAN_RTL_LINT_FILTER},-whitespace/line_length
     35 COMMON_RTL_INC_LINT_FILTER=${COMMON_LINT_FILTER},-runtime/int,-runtime/sizeof,-runtime/printf
     36 SANITIZER_INCLUDES_LINT_FILTER=${COMMON_LINT_FILTER},-runtime/int
     37 
     38 cd ${LLVM_CHECKOUT}
     39 
     40 # LLVM Instrumentation
     41 LLVM_INSTRUMENTATION=lib/Transforms/Instrumentation
     42 LLVM_LINT_FILTER=-,+whitespace
     43 ${CPPLINT} --filter=${LLVM_LINT_FILTER} lib/Transforms/Instrumentation/*Sanitizer.cpp \
     44                                         lib/Transforms/Utils/SpecialCaseList.cpp
     45 
     46 COMPILER_RT=projects/compiler-rt
     47 
     48 # Headers
     49 SANITIZER_INCLUDES=${COMPILER_RT}/include/sanitizer
     50 ${CPPLINT} --filter=${SANITIZER_INCLUDES_LINT_FILTER} ${SANITIZER_INCLUDES}/*.h
     51 
     52 # Sanitizer_common
     53 COMMON_RTL=${COMPILER_RT}/lib/sanitizer_common
     54 ${CPPLINT} --filter=${COMMON_RTL_INC_LINT_FILTER} ${COMMON_RTL}/*.{cc,h}
     55 ${CPPLINT} --filter=${COMMON_RTL_INC_LINT_FILTER} ${COMMON_RTL}/tests/*.cc
     56 
     57 # Interception
     58 INTERCEPTION=${COMPILER_RT}/lib/interception
     59 ${CPPLINT} --filter=${ASAN_RTL_LINT_FILTER} ${INTERCEPTION}/*.{cc,h}
     60 
     61 # ASan
     62 ASAN_RTL=${COMPILER_RT}/lib/asan
     63 ${CPPLINT} --filter=${ASAN_RTL_LINT_FILTER} ${ASAN_RTL}/*.{cc,h}
     64 ${CPPLINT} --filter=${ASAN_TEST_LINT_FILTER} ${ASAN_RTL}/tests/*.{cc,h}
     65 ${CPPLINT} --filter=${ASAN_LIT_TEST_LINT_FILTER} ${ASAN_RTL}/lit_tests/*/*.cc \
     66 
     67 # TSan
     68 TSAN_RTL=${COMPILER_RT}/lib/tsan
     69 ${CPPLINT} --filter=${TSAN_RTL_LINT_FILTER} ${TSAN_RTL}/rtl/*.{cc,h}
     70 ${CPPLINT} --filter=${TSAN_TEST_LINT_FILTER} ${TSAN_RTL}/tests/rtl/*.{cc,h} \
     71                                              ${TSAN_RTL}/tests/unit/*.cc
     72 ${CPPLINT} --filter=${TSAN_LIT_TEST_LINT_FILTER} ${TSAN_RTL}/lit_tests/*.cc
     73 
     74 # MSan
     75 MSAN_RTL=${COMPILER_RT}/lib/msan
     76 ${CPPLINT} --filter=${MSAN_RTL_LINT_FILTER} ${MSAN_RTL}/*.{cc,h}
     77 
     78 # LSan
     79 LSAN_RTL=${COMPILER_RT}/lib/lsan
     80 ${CPPLINT} --filter=${LSAN_RTL_LINT_FILTER} ${LSAN_RTL}/*.{cc,h}
     81 ${CPPLINT} --filter=${LSAN_RTL_LINT_FILTER} ${LSAN_RTL}/tests/*.{cc,h}
     82 ${CPPLINT} --filter=${LSAN_LIT_TEST_LINT_FILTER} ${LSAN_RTL}/lit_tests/*/*.cc
     83 
     84 set +e
     85 
     86 # Misc files
     87 FILES=${COMMON_RTL}/*.inc
     88 for FILE in $FILES; do
     89     TMPFILE=$(mktemp -u ${FILE}.XXXXX).cc
     90     echo "Checking $FILE"
     91     cp -f $FILE $TMPFILE && \
     92         ${CPPLINT} --filter=${COMMON_RTL_INC_LINT_FILTER} $TMPFILE
     93     rm $TMPFILE
     94 done
     95