[tools] Added clang syntax tools.

This commit is contained in:
Andrew Hamilton 2016-11-27 14:02:35 +01:00
parent 8f39ecf2ce
commit 2b08e4d490
5 changed files with 22 additions and 4 deletions

View file

@ -32,9 +32,9 @@ Extensions | Tools
.pl .pm .t | [perl_syntax](https://en.wikipedia.org/wiki/Perl) • [perldoc](http://perldoc.perl.org/) • [perltidy](http://perltidy.sourceforge.net/)
.pod .pod6 | [perldoc](http://perldoc.perl.org/)
.java | [uncrustify](http://uncrustify.sourceforge.net/)
.c .h | [c_syntax_gcc](https://gcc.gnu.org/) • [splint](http://www.splint.org/) • [uncrustify](http://uncrustify.sourceforge.net/)
.c .h | [c_syntax_gcc](https://gcc.gnu.org/) • [c_syntax_clang](http://clang.llvm.org/) • [splint](http://www.splint.org/) • [uncrustify](http://uncrustify.sourceforge.net/)
.o | [objdump_headers](https://en.wikipedia.org/wiki/Objdump) • [objdump_disassemble](https://en.wikipedia.org/wiki/Objdump) • [readelf](https://en.wikipedia.org/wiki/Objdump)
.cpp | [cpp_syntax_gcc](https://gcc.gnu.org/) • bcpp • [uncrustify](http://uncrustify.sourceforge.net/)
.cpp | [cpp_syntax_gcc](https://gcc.gnu.org/) • [cpp_syntax_clang](http://clang.llvm.org/) • bcpp • [uncrustify](http://uncrustify.sourceforge.net/)
.pdf | [pdf2txt](http://www.unixuser.org/~euske/python/pdfminer/)
.html | [html_syntax](http://www.html-tidy.org/) • [tidy](http://www.html-tidy.org/) • [html2text](http://www.mbayer.de/html2text/)
.php | [php5_syntax](https://en.wikipedia.org/wiki/PHP)

View file

@ -515,6 +515,12 @@ c_syntax_gcc.dependencies = {"gcc"}
c_syntax_gcc.url = "https://gcc.gnu.org/"
def c_syntax_clang(path):
return _run_command(["clang", "-fsyntax-only", path])
c_syntax_clang.dependencies = {"clang"}
c_syntax_clang.url = "http://clang.llvm.org/"
def splint(path):
stdout, stderr, returncode = _do_command(["splint", "-preproc", path])
status = Status.ok if returncode == 0 else Status.problem
@ -607,6 +613,12 @@ cpp_syntax_gcc.dependencies = {"gcc"}
cpp_syntax_gcc.url = "https://gcc.gnu.org/"
def cpp_syntax_clang(path):
return _run_command(["clang", "-fsyntax-only", path])
cpp_syntax_clang.dependencies = {"clang"}
cpp_syntax_clang.url = "http://clang.llvm.org/"
def bcpp(path):
stdout, stderr, returncode = _do_command(["bcpp", "-fi", path])
status = Status.normal if returncode == 0 else Status.problem
@ -766,9 +778,9 @@ TOOLS_FOR_EXTENSIONS = \
# (["p6", "pm6"], [perl6_syntax, perldoc]),
(["pod", "pod6"], [perldoc]),
(["java"], [uncrustify]),
(["c", "h"], [c_syntax_gcc, splint, uncrustify]),
(["c", "h"], [c_syntax_gcc, c_syntax_clang, splint, uncrustify]),
(["o"], [objdump_headers, objdump_disassemble, readelf]),
(["cpp"], [cpp_syntax_gcc, bcpp, uncrustify]),
(["cpp"], [cpp_syntax_gcc, cpp_syntax_clang, bcpp, uncrustify]),
(["pdf"], [pdf2txt]),
(["html"], [html_syntax, tidy, html2text]),
(["php"], [php5_syntax]),

View file

@ -156,6 +156,9 @@ class ToolsTestCase(unittest.TestCase):
def test_c_syntax_gcc(self):
self._test_tool(tools.c_syntax_gcc, [("hello.c", tools.Status.ok)])
def test_c_syntax_clang(self):
self._test_tool(tools.c_syntax_clang, [("hello.c", tools.Status.ok)])
def test_splint(self):
self._test_tool(tools.splint, [("hello.c", tools.Status.ok),
("hello.h", tools.Status.ok)])
@ -200,6 +203,9 @@ class ToolsTestCase(unittest.TestCase):
def test_cpp_syntax_gcc(self):
self._test_tool(tools.cpp_syntax_gcc, [("hello.cpp", tools.Status.ok)])
def test_cpp_syntax_clang(self):
self._test_tool(tools.cpp_syntax_clang, [("hello.cpp", tools.Status.ok)])
def test_bcpp(self):
self._test_tool(tools.bcpp, [("hello.cpp", tools.Status.normal)])