diff options
author | Alexey Samsonov <samsonov@google.com> | 2013-08-23 07:43:56 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2013-08-23 07:43:56 +0000 |
commit | 903c3250d25ff562736e7abb2c387cb95a504349 (patch) | |
tree | f4c5757dbaab2a4f6cf76093e8845a768f59bc48 | |
parent | 6dae24df1677bd99842330c4a9429a88feda5cb5 (diff) | |
download | bcm5719-llvm-903c3250d25ff562736e7abb2c387cb95a504349.tar.gz bcm5719-llvm-903c3250d25ff562736e7abb2c387cb95a504349.zip |
Slightly improve lint checker script and fix a few style issues
llvm-svn: 189092
3 files changed, 40 insertions, 33 deletions
diff --git a/compiler-rt/lib/lsan/lit_tests/TestCases/high_allocator_contention.cc b/compiler-rt/lib/lsan/lit_tests/TestCases/high_allocator_contention.cc index 31f2664f993..1cecb2a550a 100644 --- a/compiler-rt/lib/lsan/lit_tests/TestCases/high_allocator_contention.cc +++ b/compiler-rt/lib/lsan/lit_tests/TestCases/high_allocator_contention.cc @@ -9,12 +9,14 @@ int num_threads; int total_num_alloc; +const int kMaxNumThreads = 5000; +pthread_t tid[kMaxNumThreads]; pthread_cond_t cond = PTHREAD_COND_INITIALIZER; pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; bool go = false; -void *thread_fun(void *) { +void *thread_fun(void *arg) { pthread_mutex_lock(&mutex); while (!go) pthread_cond_wait(&cond, &mutex); pthread_mutex_unlock(&mutex); @@ -30,9 +32,9 @@ int main(int argc, char** argv) { assert(argc == 3); num_threads = atoi(argv[1]); assert(num_threads > 0); + assert(num_threads <= kMaxNumThreads); total_num_alloc = atoi(argv[2]); assert(total_num_alloc > 0); - pthread_t tid[num_threads]; printf("%d threads, %d allocations in each\n", num_threads, total_num_alloc / num_threads); for (int i = 0; i < num_threads; i++) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc index c0b13d1b270..436a34dc26b 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -1853,7 +1853,7 @@ INTERCEPTOR(int, scandir, char *dirp, __sanitizer_dirent ***namelist, void *ctx; COMMON_INTERCEPTOR_ENTER(ctx, scandir, dirp, namelist, filter, compar); if (dirp) COMMON_INTERCEPTOR_READ_RANGE(ctx, dirp, REAL(strlen)(dirp) + 1); - CHECK(scandir_ctx == 0); + CHECK_EQ(0, scandir_ctx); scandir_ctx = ctx; scandir_filter = filter; scandir_compar = compar; @@ -1906,7 +1906,7 @@ INTERCEPTOR(int, scandir64, char *dirp, __sanitizer_dirent64 ***namelist, void *ctx; COMMON_INTERCEPTOR_ENTER(ctx, scandir64, dirp, namelist, filter, compar); if (dirp) COMMON_INTERCEPTOR_READ_RANGE(ctx, dirp, REAL(strlen)(dirp) + 1); - CHECK(scandir64_ctx == 0); + CHECK_EQ(0, scandir64_ctx); scandir64_ctx = ctx; scandir64_filter = filter; scandir64_compar = compar; @@ -1956,7 +1956,8 @@ static void read_pollfd(void *ctx, __sanitizer_pollfd *fds, static void write_pollfd(void *ctx, __sanitizer_pollfd *fds, __sanitizer_nfds_t nfds) { for (unsigned i = 0; i < nfds; ++i) - COMMON_INTERCEPTOR_WRITE_RANGE(ctx, &fds[i].revents, sizeof(fds[i].revents)); + COMMON_INTERCEPTOR_WRITE_RANGE(ctx, &fds[i].revents, + sizeof(fds[i].revents)); } INTERCEPTOR(int, poll, __sanitizer_pollfd *fds, __sanitizer_nfds_t nfds, diff --git a/compiler-rt/lib/sanitizer_common/scripts/check_lint.sh b/compiler-rt/lib/sanitizer_common/scripts/check_lint.sh index e3fd36950b2..34b4f56590c 100755 --- a/compiler-rt/lib/sanitizer_common/scripts/check_lint.sh +++ b/compiler-rt/lib/sanitizer_common/scripts/check_lint.sh @@ -1,7 +1,5 @@ #!/bin/bash -set -e - SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" # Guess path to LLVM_CHECKOUT if not provided @@ -21,6 +19,7 @@ CPPLINT=${SCRIPT_DIR}/cpplint/cpplint.py # Filters # TODO: remove some of these filters +LLVM_LINT_FILTER=-,+whitespace COMMON_LINT_FILTER=-build/include,-build/header_guard,-legal/copyright,-whitespace/comments,-readability/casting,\ -build/namespaces ASAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER},-runtime/int @@ -37,54 +36,57 @@ SANITIZER_INCLUDES_LINT_FILTER=${COMMON_LINT_FILTER},-runtime/int cd ${LLVM_CHECKOUT} -# FIXME: We should use some bash magic to continue cpplint invocations, but -# still mark the whole run as failed if any invocation fails. +EXITSTATUS=0 -# LLVM Instrumentation -LLVM_INSTRUMENTATION=lib/Transforms/Instrumentation -LLVM_LINT_FILTER=-,+whitespace -${CPPLINT} --filter=${LLVM_LINT_FILTER} lib/Transforms/Instrumentation/*Sanitizer.cpp \ - lib/Transforms/Utils/SpecialCaseList.cpp +run_lint() { + FILTER=$1 + shift + ${CPPLINT} --filter=${FILTER} "$@" + if [ "$?" != "0" ]; then + EXITSTATUS=1 + fi +} -COMPILER_RT=projects/compiler-rt +run_lint ${LLVM_LINT_FILTER} --filter=${LLVM_LINT_FILTER} \ + lib/Transforms/Instrumentation/*Sanitizer.cpp \ + lib/Transforms/Utils/SpecialCaseList.cpp +COMPILER_RT=projects/compiler-rt # Headers SANITIZER_INCLUDES=${COMPILER_RT}/include/sanitizer -${CPPLINT} --filter=${SANITIZER_INCLUDES_LINT_FILTER} ${SANITIZER_INCLUDES}/*.h +run_lint ${SANITIZER_INCLUDES_LINT_FILTER} ${SANITIZER_INCLUDES}/*.h # Sanitizer_common COMMON_RTL=${COMPILER_RT}/lib/sanitizer_common -${CPPLINT} --filter=${COMMON_RTL_INC_LINT_FILTER} ${COMMON_RTL}/*.{cc,h} -${CPPLINT} --filter=${COMMON_RTL_INC_LINT_FILTER} ${COMMON_RTL}/tests/*.cc +run_lint ${COMMON_RTL_INC_LINT_FILTER} ${COMMON_RTL}/*.{cc,h} \ + ${COMMON_RTL}/tests/*.cc # Interception INTERCEPTION=${COMPILER_RT}/lib/interception -${CPPLINT} --filter=${ASAN_RTL_LINT_FILTER} ${INTERCEPTION}/*.{cc,h} +run_lint ${ASAN_RTL_LINT_FILTER} ${INTERCEPTION}/*.{cc,h} # ASan ASAN_RTL=${COMPILER_RT}/lib/asan -${CPPLINT} --filter=${ASAN_RTL_LINT_FILTER} ${ASAN_RTL}/*.{cc,h} -${CPPLINT} --filter=${ASAN_TEST_LINT_FILTER} ${ASAN_RTL}/tests/*.{cc,h} -${CPPLINT} --filter=${ASAN_LIT_TEST_LINT_FILTER} ${ASAN_RTL}/lit_tests/*/*.cc \ +run_lint ${ASAN_RTL_LINT_FILTER} ${ASAN_RTL}/*.{cc,h} +run_lint ${ASAN_TEST_LINT_FILTER} ${ASAN_RTL}/tests/*.{cc,h} +run_lint ${ASAN_LIT_TEST_LINT_FILTER} ${ASAN_RTL}/lit_tests/*/*.cc # TSan TSAN_RTL=${COMPILER_RT}/lib/tsan -${CPPLINT} --filter=${TSAN_RTL_LINT_FILTER} ${TSAN_RTL}/rtl/*.{cc,h} -${CPPLINT} --filter=${TSAN_TEST_LINT_FILTER} ${TSAN_RTL}/tests/rtl/*.{cc,h} \ - ${TSAN_RTL}/tests/unit/*.cc -${CPPLINT} --filter=${TSAN_LIT_TEST_LINT_FILTER} ${TSAN_RTL}/lit_tests/*.cc +run_lint ${TSAN_RTL_LINT_FILTER} ${TSAN_RTL}/rtl/*.{cc,h} +run_lint ${TSAN_TEST_LINT_FILTER} ${TSAN_RTL}/tests/rtl/*.{cc,h} \ + ${TSAN_RTL}/tests/unit/*.cc +run_lint ${TSAN_LIT_TEST_LINT_FILTER} ${TSAN_RTL}/lit_tests/*.cc # MSan MSAN_RTL=${COMPILER_RT}/lib/msan -${CPPLINT} --filter=${MSAN_RTL_LINT_FILTER} ${MSAN_RTL}/*.{cc,h} +run_lint ${MSAN_RTL_LINT_FILTER} ${MSAN_RTL}/*.{cc,h} # LSan LSAN_RTL=${COMPILER_RT}/lib/lsan -${CPPLINT} --filter=${LSAN_RTL_LINT_FILTER} ${LSAN_RTL}/*.{cc,h} -${CPPLINT} --filter=${LSAN_RTL_LINT_FILTER} ${LSAN_RTL}/tests/*.{cc,h} -${CPPLINT} --filter=${LSAN_LIT_TEST_LINT_FILTER} ${LSAN_RTL}/lit_tests/*/*.cc - -set +e +run_lint ${LSAN_RTL_LINT_FILTER} ${LSAN_RTL}/*.{cc,h} +run_lint ${LSAN_RTL_LINT_FILTER} ${LSAN_RTL}/tests/*.{cc,h} +run_lint ${LSAN_LIT_TEST_LINT_FILTER} ${LSAN_RTL}/lit_tests/*/*.cc # Misc files FILES=${COMMON_RTL}/*.inc @@ -92,6 +94,8 @@ for FILE in $FILES; do TMPFILE=$(mktemp -u ${FILE}.XXXXX).cc echo "Checking $FILE" cp -f $FILE $TMPFILE && \ - ${CPPLINT} --filter=${COMMON_RTL_INC_LINT_FILTER} $TMPFILE + run_lint ${COMMON_RTL_INC_LINT_FILTER} $TMPFILE rm $TMPFILE done + +exit $EXITSTATUS |