You've already forked linux-packaging-mono
acceptance-tests
data
debian
docs
external
Newtonsoft.Json
api-doc-tools
api-snapshot
aspnetwebstack
binary-reference-assemblies
bockbuild
boringssl
cecil
cecil-legacy
corefx
corert
helix-binaries
ikdasm
ikvm
illinker-test-assets
linker
llvm
bindings
cmake
docs
examples
include
lib
projects
resources
runtimes
scripts
test
tools
unittests
utils
FileCheck
KillTheDoctor
LLVMVisualizers
Misc
PerfectShuffle
TableGen
Target
bugpoint
count
crosstool
docker
emacs
fpcmp
gdb-scripts
git
git-svn
jedit
kate
lint
common_lint.py
cpp_lint.py
generic_lint.py
remove_trailing_whitespace.sh
lit
llvm-build
llvm-lit
not
release
sanitizers
testgen
textmate
unittest
valgrind
vim
vscode
yaml-bench
DSAclean.py
DSAextract.py
GenLibDeps.pl
GetRepositoryPath
GetSourceVersion
LLVMBuild.txt
UpdateCMakeLists.pl
abtest.py
bisect
bisect-skip-count
check-each-file
clang-parse-diagnostics-file
codegen-diff
countloc.sh
create_ladder_graph.py
extract_symbols.py
findmisopt
findoptdiff
findsym.pl
getsrcs.sh
lldbDataFormatters.py
llvm-compilers-check
llvm-gisel-cov.py
llvm-native-gxx
llvm.grm
llvmdo
llvmgrep
makellvm
prepare-code-coverage-artifact.py
schedcover.py
shuffle_fuzz.py
shuffle_select_fuzz_tester.py
sort_includes.py
update_llc_test_checks.py
update_mir_test_checks.py
update_test_checks.py
wciia.py
.arcconfig
.clang-format
.clang-tidy
.gitattributes
.gitignore
CMakeLists.txt
CODE_OWNERS.TXT
CREDITS.TXT
LICENSE.TXT
LLVMBuild.txt
README.txt
RELEASE_TESTERS.TXT
configure
llvm.spec.in
nuget-buildtasks
nunit-lite
roslyn-binaries
rx
xunit-binaries
how-to-bump-roslyn-binaries.md
ikvm-native
libgc
llvm
m4
man
mcs
mk
mono
msvc
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
95 lines
3.0 KiB
Python
95 lines
3.0 KiB
Python
![]() |
#!/usr/bin/python
|
||
|
#
|
||
|
# Checks C++ files to make sure they conform to LLVM standards, as specified in
|
||
|
# http://llvm.org/docs/CodingStandards.html .
|
||
|
#
|
||
|
# TODO: add unittests for the verifier functions:
|
||
|
# http://docs.python.org/library/unittest.html .
|
||
|
|
||
|
import common_lint
|
||
|
import re
|
||
|
import sys
|
||
|
|
||
|
def VerifyIncludes(filename, lines):
|
||
|
"""Makes sure the #includes are in proper order and no disallows files are
|
||
|
#included.
|
||
|
|
||
|
Args:
|
||
|
filename: the file under consideration as string
|
||
|
lines: contents of the file as string array
|
||
|
"""
|
||
|
lint = []
|
||
|
|
||
|
include_gtest_re = re.compile(r'^#include "gtest/(.*)"')
|
||
|
include_llvm_re = re.compile(r'^#include "llvm/(.*)"')
|
||
|
include_support_re = re.compile(r'^#include "(Support/.*)"')
|
||
|
include_config_re = re.compile(r'^#include "(Config/.*)"')
|
||
|
include_system_re = re.compile(r'^#include <(.*)>')
|
||
|
|
||
|
DISALLOWED_SYSTEM_HEADERS = ['iostream']
|
||
|
|
||
|
line_num = 1
|
||
|
prev_config_header = None
|
||
|
prev_system_header = None
|
||
|
for line in lines:
|
||
|
# TODO: implement private headers
|
||
|
# TODO: implement gtest headers
|
||
|
# TODO: implement top-level llvm/* headers
|
||
|
# TODO: implement llvm/Support/* headers
|
||
|
|
||
|
# Process Config/* headers
|
||
|
config_header = include_config_re.match(line)
|
||
|
if config_header:
|
||
|
curr_config_header = config_header.group(1)
|
||
|
if prev_config_header:
|
||
|
if prev_config_header > curr_config_header:
|
||
|
lint.append((filename, line_num,
|
||
|
'Config headers not in order: "%s" before "%s"' % (
|
||
|
prev_config_header, curr_config_header)))
|
||
|
|
||
|
# Process system headers
|
||
|
system_header = include_system_re.match(line)
|
||
|
if system_header:
|
||
|
curr_system_header = system_header.group(1)
|
||
|
|
||
|
# Is it blacklisted?
|
||
|
if curr_system_header in DISALLOWED_SYSTEM_HEADERS:
|
||
|
lint.append((filename, line_num,
|
||
|
'Disallowed system header: <%s>' % curr_system_header))
|
||
|
elif prev_system_header:
|
||
|
# Make sure system headers are alphabetized amongst themselves
|
||
|
if prev_system_header > curr_system_header:
|
||
|
lint.append((filename, line_num,
|
||
|
'System headers not in order: <%s> before <%s>' % (
|
||
|
prev_system_header, curr_system_header)))
|
||
|
|
||
|
prev_system_header = curr_system_header
|
||
|
|
||
|
line_num += 1
|
||
|
|
||
|
return lint
|
||
|
|
||
|
|
||
|
class CppLint(common_lint.BaseLint):
|
||
|
MAX_LINE_LENGTH = 80
|
||
|
|
||
|
def RunOnFile(self, filename, lines):
|
||
|
lint = []
|
||
|
lint.extend(VerifyIncludes(filename, lines))
|
||
|
lint.extend(common_lint.VerifyLineLength(filename, lines,
|
||
|
CppLint.MAX_LINE_LENGTH))
|
||
|
lint.extend(common_lint.VerifyTabs(filename, lines))
|
||
|
lint.extend(common_lint.VerifyTrailingWhitespace(filename, lines))
|
||
|
return lint
|
||
|
|
||
|
|
||
|
def CppLintMain(filenames):
|
||
|
all_lint = common_lint.RunLintOverAllFiles(CppLint(), filenames)
|
||
|
for lint in all_lint:
|
||
|
print '%s:%d:%s' % (lint[0], lint[1], lint[2])
|
||
|
return 0
|
||
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
sys.exit(CppLintMain(sys.argv[1:]))
|