summaryrefslogtreecommitdiffstats
path: root/llvm/utils/lint/cpp_lint.py
diff options
context:
space:
mode:
authorMisha Brukman <brukman+llvm@gmail.com>2009-02-20 23:44:54 +0000
committerMisha Brukman <brukman+llvm@gmail.com>2009-02-20 23:44:54 +0000
commit0f35659b9aaad4e6d0883b9d1a6999b4c1022418 (patch)
treef56892d825d31a6c2f79122149d07dcc2b841cd7 /llvm/utils/lint/cpp_lint.py
parente7fe80fcf927f94f39c4707acd3c4027b70d7745 (diff)
downloadbcm5719-llvm-0f35659b9aaad4e6d0883b9d1a6999b4c1022418.tar.gz
bcm5719-llvm-0f35659b9aaad4e6d0883b9d1a6999b4c1022418.zip
* Fixed spelling
* Linters now return their information instead of printing it, to enable easier unittesting * Added support for finding tabs in files, added to C++ linter llvm-svn: 65202
Diffstat (limited to 'llvm/utils/lint/cpp_lint.py')
-rwxr-xr-xllvm/utils/lint/cpp_lint.py32
1 files changed, 22 insertions, 10 deletions
diff --git a/llvm/utils/lint/cpp_lint.py b/llvm/utils/lint/cpp_lint.py
index ca81bfe35d8..07fad5840fd 100755
--- a/llvm/utils/lint/cpp_lint.py
+++ b/llvm/utils/lint/cpp_lint.py
@@ -18,6 +18,8 @@ def VerifyIncludes(filename, lines):
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/.*)"')
@@ -41,8 +43,9 @@ def VerifyIncludes(filename, lines):
curr_config_header = config_header.group(1)
if prev_config_header:
if prev_config_header > curr_config_header:
- print '%s:%d:Config headers not in order: "%s" before "%s" ' % (
- filename, line_num, 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)
@@ -51,30 +54,39 @@ def VerifyIncludes(filename, lines):
# Is it blacklisted?
if curr_system_header in DISALLOWED_SYSTEM_HEADERS:
- print '%s:%d:Disallowed system header: <%s>' % (
- filename, line_num, curr_system_header)
+ 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:
- print '%s:%d:System headers not in order: <%s> before <%s>' % (
- filename, line_num, 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):
- VerifyIncludes(filename, lines)
- common_lint.VerifyLineLength(filename, lines, CppLint.MAX_LINE_LENGTH)
- common_lint.VerifyTrailingWhitespace(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):
- common_lint.RunLintOverAllFiles(CppLint(), 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
OpenPOWER on IntegriCloud