forked from OSchip/llvm-project
[sanitizer] Remove cpplint
As code diverge from Google style we need to add more and more exceptions to suppress conflicts with clang-format and clang-tidy. As this point it does not provide a additional value. Reviewed By: morehouse Differential Revision: https://reviews.llvm.org/D107197
This commit is contained in:
parent
3338ef93b0
commit
f08229f49e
|
@ -3,9 +3,6 @@ include(CompilerRTUtils)
|
|||
set(SANITIZER_GEN_DYNAMIC_LIST
|
||||
${COMPILER_RT_SOURCE_DIR}/lib/sanitizer_common/scripts/gen_dynamic_list.py)
|
||||
|
||||
set(SANITIZER_LINT_SCRIPT
|
||||
${COMPILER_RT_SOURCE_DIR}/lib/sanitizer_common/scripts/check_lint.sh)
|
||||
|
||||
if(CMAKE_NM)
|
||||
set(SANITIZER_NM "${CMAKE_NM}")
|
||||
else()
|
||||
|
@ -95,20 +92,3 @@ macro(add_sanitizer_rt_version_list name)
|
|||
add_custom_target(${name}-version-list ALL
|
||||
DEPENDS ${vers})
|
||||
endmacro()
|
||||
|
||||
# Add target to check code style for sanitizer runtimes.
|
||||
if(CMAKE_HOST_UNIX AND NOT OS_NAME MATCHES "OpenBSD")
|
||||
add_custom_target(SanitizerLintCheck
|
||||
COMMAND env LLVM_CHECKOUT=${LLVM_MAIN_SRC_DIR} SILENT=1 TMPDIR=
|
||||
PYTHON_EXECUTABLE=${Python3_EXECUTABLE}
|
||||
COMPILER_RT=${COMPILER_RT_SOURCE_DIR}
|
||||
${SANITIZER_LINT_SCRIPT}
|
||||
DEPENDS ${SANITIZER_LINT_SCRIPT}
|
||||
COMMENT "Running lint check for sanitizer sources..."
|
||||
VERBATIM)
|
||||
else()
|
||||
add_custom_target(SanitizerLintCheck
|
||||
COMMAND echo "No lint check")
|
||||
endif()
|
||||
set_target_properties(SanitizerLintCheck
|
||||
PROPERTIES FOLDER "Compiler-RT Misc")
|
||||
|
|
|
@ -1,141 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
|
||||
if [ "${COMPILER_RT}" = "" ]; then
|
||||
COMPILER_RT=$(readlink -f $SCRIPT_DIR/../../..)
|
||||
fi
|
||||
|
||||
# python tools setup
|
||||
CPPLINT=${SCRIPT_DIR}/cpplint.py
|
||||
LITLINT=${SCRIPT_DIR}/litlint.py
|
||||
if [ "${PYTHON_EXECUTABLE}" != "" ]; then
|
||||
CPPLINT="${PYTHON_EXECUTABLE} ${CPPLINT}"
|
||||
LITLINT="${PYTHON_EXECUTABLE} ${LITLINT}"
|
||||
fi
|
||||
|
||||
# Filters
|
||||
# TODO: remove some of these filters
|
||||
COMMON_LINT_FILTER=-build/include,-build/header_guard,-legal/copyright,-whitespace/comments,-readability/casting,\
|
||||
-build/namespaces,-build/c++11,-runtime/int,-runtime/references,-readability/todo,-whitespace/parens
|
||||
|
||||
COMMON_LIT_TEST_LINT_FILTER=-whitespace/indent,-whitespace/line_length,-runtime/arrays,-readability/braces
|
||||
|
||||
ASAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER}
|
||||
ASAN_TEST_LINT_FILTER=${COMMON_LINT_FILTER},-runtime/printf,-runtime/threadsafe_fn
|
||||
ASAN_LIT_TEST_LINT_FILTER=${ASAN_TEST_LINT_FILTER},${COMMON_LIT_TEST_LINT_FILTER}
|
||||
|
||||
TSAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER},-readability/braces
|
||||
TSAN_TEST_LINT_FILTER=${TSAN_RTL_LINT_FILTER},-runtime/threadsafe_fn
|
||||
TSAN_LIT_TEST_LINT_FILTER=${TSAN_TEST_LINT_FILTER},${COMMON_LIT_TEST_LINT_FILTER}
|
||||
|
||||
MSAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER}
|
||||
|
||||
LSAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER}
|
||||
LSAN_LIT_TEST_LINT_FILTER=${LSAN_RTL_LINT_FILTER},${COMMON_LIT_TEST_LINT_FILTER}
|
||||
|
||||
DFSAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER}
|
||||
SCUDO_RTL_LINT_FILTER=${COMMON_LINT_FILTER}
|
||||
|
||||
COMMON_RTL_INC_LINT_FILTER=${COMMON_LINT_FILTER}
|
||||
|
||||
SANITIZER_INCLUDES_LINT_FILTER=${COMMON_LINT_FILTER}
|
||||
|
||||
MKTEMP_DIR=$(mktemp -qd /tmp/check_lint.XXXXXXXXXX)
|
||||
MKTEMP="mktemp -q ${MKTEMP_DIR}/tmp.XXXXXXXXXX"
|
||||
cleanup() {
|
||||
rm -rf $MKTEMP_DIR
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
EXITSTATUS=0
|
||||
ERROR_LOG=$(${MKTEMP})
|
||||
|
||||
run_lint() {
|
||||
FILTER=$1
|
||||
shift
|
||||
TASK_LOG=$(${MKTEMP})
|
||||
${CPPLINT} --filter=${FILTER} "$@" > $TASK_LOG 2>&1
|
||||
if [ "$?" != "0" ]; then
|
||||
cat $TASK_LOG | grep -v "Done processing" | grep -v "Total errors found" \
|
||||
| grep -v "Skipping input" >> $ERROR_LOG
|
||||
fi
|
||||
if [ "${SILENT}" != "1" ]; then
|
||||
cat $TASK_LOG
|
||||
fi
|
||||
${LITLINT} "$@" 2>>$ERROR_LOG
|
||||
}
|
||||
|
||||
LIT_TESTS=${COMPILER_RT}/test
|
||||
# Headers
|
||||
SANITIZER_INCLUDES=${COMPILER_RT}/include/sanitizer
|
||||
FUZZER_INCLUDES=${COMPILER_RT}/include/fuzzer
|
||||
run_lint ${SANITIZER_INCLUDES_LINT_FILTER} ${SANITIZER_INCLUDES}/*.h \
|
||||
${FUZZER_INCLUDES}/*.h &
|
||||
|
||||
# Sanitizer_common
|
||||
COMMON_RTL=${COMPILER_RT}/lib/sanitizer_common
|
||||
run_lint ${COMMON_RTL_INC_LINT_FILTER} ${COMMON_RTL}/*.cpp \
|
||||
${COMMON_RTL}/*.h \
|
||||
${COMMON_RTL}/tests/*.cpp &
|
||||
|
||||
# Interception
|
||||
INTERCEPTION=${COMPILER_RT}/lib/interception
|
||||
run_lint ${ASAN_RTL_LINT_FILTER} ${INTERCEPTION}/*.cpp \
|
||||
${INTERCEPTION}/*.h &
|
||||
|
||||
# ASan
|
||||
ASAN_RTL=${COMPILER_RT}/lib/asan
|
||||
run_lint ${ASAN_RTL_LINT_FILTER} ${ASAN_RTL}/*.cpp \
|
||||
${ASAN_RTL}/*.h &
|
||||
run_lint ${ASAN_TEST_LINT_FILTER} ${ASAN_RTL}/tests/*.cpp \
|
||||
${ASAN_RTL}/tests/*.h &
|
||||
run_lint ${ASAN_LIT_TEST_LINT_FILTER} ${LIT_TESTS}/asan/*/*.cpp &
|
||||
|
||||
# TSan
|
||||
TSAN_RTL=${COMPILER_RT}/lib/tsan
|
||||
run_lint ${TSAN_RTL_LINT_FILTER} ${TSAN_RTL}/rtl/*.cpp \
|
||||
${TSAN_RTL}/rtl/*.h &
|
||||
run_lint ${TSAN_TEST_LINT_FILTER} ${TSAN_RTL}/tests/rtl/*.cpp \
|
||||
${TSAN_RTL}/tests/rtl/*.h \
|
||||
${TSAN_RTL}/tests/unit/*.cpp &
|
||||
run_lint ${TSAN_LIT_TEST_LINT_FILTER} ${LIT_TESTS}/tsan/*.cpp &
|
||||
|
||||
# MSan
|
||||
MSAN_RTL=${COMPILER_RT}/lib/msan
|
||||
run_lint ${MSAN_RTL_LINT_FILTER} ${MSAN_RTL}/*.cpp \
|
||||
${MSAN_RTL}/*.h &
|
||||
|
||||
# LSan
|
||||
LSAN_RTL=${COMPILER_RT}/lib/lsan
|
||||
run_lint ${LSAN_RTL_LINT_FILTER} ${LSAN_RTL}/*.cpp \
|
||||
${LSAN_RTL}/*.h &
|
||||
run_lint ${LSAN_LIT_TEST_LINT_FILTER} ${LIT_TESTS}/lsan/*/*.cpp &
|
||||
|
||||
# DFSan
|
||||
DFSAN_RTL=${COMPILER_RT}/lib/dfsan
|
||||
run_lint ${DFSAN_RTL_LINT_FILTER} ${DFSAN_RTL}/*.cpp \
|
||||
${DFSAN_RTL}/*.h &
|
||||
${DFSAN_RTL}/scripts/check_custom_wrappers.sh >> $ERROR_LOG
|
||||
|
||||
# Scudo
|
||||
SCUDO_RTL=${COMPILER_RT}/lib/scudo
|
||||
run_lint ${SCUDO_RTL_LINT_FILTER} ${SCUDO_RTL}/*.cpp \
|
||||
${SCUDO_RTL}/*.h &
|
||||
|
||||
# Misc files
|
||||
(
|
||||
rsync -a --prune-empty-dirs --exclude='*/profile/*' --exclude='*/builtins/*' --exclude='*/xray/*' --include='*/' --include='*.inc' --exclude='*' "${COMPILER_RT}/" "${MKTEMP_DIR}/"
|
||||
find ${MKTEMP_DIR} -type f -name '*.inc' -exec mv {} {}.cpp \;
|
||||
( ERROR_LOG=${ERROR_LOG}.inc run_lint ${COMMON_RTL_INC_LINT_FILTER} $(find ${MKTEMP_DIR} -type f -name '*.inc.cpp') )
|
||||
sed "s|${MKTEMP_DIR}|${COMPILER_RT}|g" ${ERROR_LOG}.inc | sed "s|.inc.cpp|.inc|g" >> ${ERROR_LOG}
|
||||
) &
|
||||
|
||||
wait
|
||||
|
||||
if [ -s $ERROR_LOG ]; then
|
||||
cat $ERROR_LOG
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
File diff suppressed because it is too large
Load Diff
|
@ -1,73 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# litlint
|
||||
#
|
||||
# Ensure RUN commands in lit tests are free of common errors.
|
||||
#
|
||||
# If any errors are detected, litlint returns a nonzero exit code.
|
||||
#
|
||||
|
||||
import optparse
|
||||
import re
|
||||
import sys
|
||||
from io import open
|
||||
|
||||
# Compile regex once for all files
|
||||
runRegex = re.compile(r'(?<!-o)(?<!%run) %t\s')
|
||||
|
||||
def LintLine(s):
|
||||
""" Validate a line
|
||||
|
||||
Args:
|
||||
s: str, the line to validate
|
||||
|
||||
Returns:
|
||||
Returns an error message and a 1-based column number if an error was
|
||||
detected, otherwise (None, None).
|
||||
"""
|
||||
|
||||
# Check that RUN command can be executed with an emulator
|
||||
m = runRegex.search(s)
|
||||
if m:
|
||||
start, end = m.span()
|
||||
return ('missing %run before %t', start + 2)
|
||||
|
||||
# No errors
|
||||
return (None, None)
|
||||
|
||||
|
||||
def LintFile(p):
|
||||
""" Check that each RUN command can be executed with an emulator
|
||||
|
||||
Args:
|
||||
p: str, valid path to a file
|
||||
|
||||
Returns:
|
||||
The number of errors detected.
|
||||
"""
|
||||
errs = 0
|
||||
with open(p, 'r', encoding='utf-8') as f:
|
||||
for i, s in enumerate(f.readlines(), start=1):
|
||||
msg, col = LintLine(s)
|
||||
if msg != None:
|
||||
errs += 1
|
||||
errorMsg = 'litlint: {}:{}:{}: error: {}.\n{}{}\n'
|
||||
arrow = (col-1) * ' ' + '^'
|
||||
sys.stderr.write(errorMsg.format(p, i, col, msg, s, arrow))
|
||||
return errs
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Parse args
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option('--filter') # ignored
|
||||
(options, filenames) = parser.parse_args()
|
||||
|
||||
# Lint each file
|
||||
errs = 0
|
||||
for p in filenames:
|
||||
errs += LintFile(p)
|
||||
|
||||
# If errors, return nonzero
|
||||
if errs > 0:
|
||||
sys.exit(1)
|
|
@ -1,23 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Tests for litlint.py
|
||||
#
|
||||
# Usage: python litlint_test.py
|
||||
#
|
||||
# Returns nonzero if any test fails
|
||||
|
||||
import litlint
|
||||
import unittest
|
||||
|
||||
class TestLintLine(unittest.TestCase):
|
||||
def test_missing_run(self):
|
||||
f = litlint.LintLine
|
||||
self.assertEqual(f(' %t '), ('missing %run before %t', 2))
|
||||
self.assertEqual(f(' %t\n'), ('missing %run before %t', 2))
|
||||
self.assertEqual(f(' %t.so '), (None, None))
|
||||
self.assertEqual(f(' %t.o '), (None, None))
|
||||
self.assertEqual(f('%run %t '), (None, None))
|
||||
self.assertEqual(f('-o %t '), (None, None))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
|
@ -2,10 +2,6 @@ set(SANITIZER_COMMON_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|||
|
||||
set(SANITIZER_COMMON_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS})
|
||||
|
||||
if(CMAKE_HOST_UNIX)
|
||||
list(APPEND SANITIZER_COMMON_TEST_DEPS SanitizerLintCheck)
|
||||
endif()
|
||||
|
||||
set(SANITIZER_COMMON_TESTSUITES)
|
||||
|
||||
# FIXME(dliew): We should switch to COMPILER_RT_SANITIZERS_TO_BUILD instead of
|
||||
|
|
Loading…
Reference in New Issue