diff --git a/README.md b/README.md index c849b7e..73d529b 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/golden-files/results/c_syntax_clang-hello_c b/golden-files/results/c_syntax_clang-hello_c new file mode 100644 index 0000000..e69de29 diff --git a/golden-files/results/cpp_syntax_clang-hello_cpp b/golden-files/results/cpp_syntax_clang-hello_cpp new file mode 100644 index 0000000..e69de29 diff --git a/tools.py b/tools.py index f98182c..b416f24 100644 --- a/tools.py +++ b/tools.py @@ -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]), diff --git a/tools_test.py b/tools_test.py index 2abf096..2a4592d 100755 --- a/tools_test.py +++ b/tools_test.py @@ -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)])