Sean Silva | f2a472a | 2013-02-19 17:29:01 +0000 | [diff] [blame] | 1 | ======================= |
| 2 | External Clang Examples |
| 3 | ======================= |
Sean Silva | 63c3af6 | 2013-02-19 16:58:15 +0000 | [diff] [blame] | 4 | |
Sean Silva | e3931a1 | 2013-02-19 17:21:23 +0000 | [diff] [blame] | 5 | Introduction |
| 6 | ============ |
Sean Silva | 63c3af6 | 2013-02-19 16:58:15 +0000 | [diff] [blame] | 7 | |
Sean Silva | e3931a1 | 2013-02-19 17:21:23 +0000 | [diff] [blame] | 8 | This page provides some examples of the kinds of things that people have |
| 9 | done with Clang that might serve as useful guides (or starting points) from |
| 10 | which to develop your own tools. They may be helpful even for something as |
| 11 | banal (but necessary) as how to set up your build to integrate Clang. |
| 12 | |
| 13 | Clang's library-based design is deliberately aimed at facilitating use by |
| 14 | external projects, and we are always interested in improving Clang to |
| 15 | better serve our external users. Some typical categories of applications |
| 16 | where Clang is used are: |
| 17 | |
| 18 | - Static analysis. |
| 19 | - Documentation/cross-reference generation. |
| 20 | |
| 21 | If you know of (or wrote!) a tool or project using Clang, please send an |
| 22 | email to Clang's `development discussion mailing list |
Eugene Zelenko | adcb3f5 | 2019-01-23 20:39:07 +0000 | [diff] [blame] | 23 | <https://lists.llvm.org/mailman/listinfo/cfe-dev>`_ to have it added. |
Sean Silva | e3931a1 | 2013-02-19 17:21:23 +0000 | [diff] [blame] | 24 | (or if you are already a Clang contributor, feel free to directly commit |
| 25 | additions). Since the primary purpose of this page is to provide examples |
| 26 | that can help developers, generally they must have code available. |
Sean Silva | 63c3af6 | 2013-02-19 16:58:15 +0000 | [diff] [blame] | 27 | |
| 28 | List of projects and tools |
| 29 | ========================== |
| 30 | |
Sean Silva | 983caaa | 2013-03-12 16:07:31 +0000 | [diff] [blame] | 31 | `<https://github.com/Andersbakken/rtags/>`_ |
| 32 | "RTags is a client/server application that indexes c/c++ code and keeps |
| 33 | a persistent in-memory database of references, symbolnames, completions |
| 34 | etc." |
| 35 | |
Eugene Zelenko | adcb3f5 | 2019-01-23 20:39:07 +0000 | [diff] [blame] | 36 | `<https://rprichard.github.com/sourceweb/>`_ |
Sean Silva | 03bfc67 | 2013-03-12 02:11:17 +0000 | [diff] [blame] | 37 | "A C/C++ source code indexer and navigator" |
| 38 | |
Sean Silva | 63c3af6 | 2013-02-19 16:58:15 +0000 | [diff] [blame] | 39 | `<https://github.com/etaoins/qconnectlint>`_ |
| 40 | "qconnectlint is a Clang tool for statically verifying the consistency |
| 41 | of signal and slot connections made with Qt's ``QObject::connect``." |
| 42 | |
| 43 | `<https://github.com/woboq/woboq_codebrowser>`_ |
| 44 | "The Woboq Code Browser is a web-based code browser for C/C++ projects. |
Eugene Zelenko | adcb3f5 | 2019-01-23 20:39:07 +0000 | [diff] [blame] | 45 | Check out `<https://code.woboq.org/>`_ for an example!" |
Sean Silva | 63c3af6 | 2013-02-19 16:58:15 +0000 | [diff] [blame] | 46 | |
| 47 | `<https://github.com/mozilla/dxr>`_ |
| 48 | "DXR is a source code cross-reference tool that uses static analysis |
| 49 | data collected by instrumented compilers." |
| 50 | |
| 51 | `<https://github.com/eschulte/clang-mutate>`_ |
| 52 | "This tool performs a number of operations on C-language source files." |
| 53 | |
| 54 | `<https://github.com/gmarpons/Crisp>`_ |
| 55 | "A coding rule validation add-on for LLVM/clang. Crisp rules are written |
| 56 | in Prolog. A high-level declarative DSL to easily write new rules is under |
| 57 | development. It will be called CRISP, an acronym for *Coding Rules in |
| 58 | Sugared Prolog*." |
| 59 | |
| 60 | `<https://github.com/drothlis/clang-ctags>`_ |
| 61 | "Generate tag file for C++ source code." |
| 62 | |
| 63 | `<https://github.com/exclipy/clang_indexer>`_ |
| 64 | "This is an indexer for C and C++ based on the libclang library." |
| 65 | |
| 66 | `<https://github.com/holtgrewe/linty>`_ |
| 67 | "Linty - C/C++ Style Checking with Python & libclang." |
| 68 | |
| 69 | `<https://github.com/axw/cmonster>`_ |
| 70 | "cmonster is a Python wrapper for the Clang C++ parser." |
| 71 | |
| 72 | `<https://github.com/rizsotto/Constantine>`_ |
Sean Silva | e3931a1 | 2013-02-19 17:21:23 +0000 | [diff] [blame] | 73 | "Constantine is a toy project to learn how to write clang plugin. |
Sean Silva | 63c3af6 | 2013-02-19 16:58:15 +0000 | [diff] [blame] | 74 | Implements pseudo const analysis. Generates warnings about variables, |
| 75 | which were declared without const qualifier." |
| 76 | |
| 77 | `<https://github.com/jessevdk/cldoc>`_ |
| 78 | "cldoc is a Clang based documentation generator for C and C++. |
| 79 | cldoc tries to solve the issue of writing C/C++ software documentation |
| 80 | with a modern, non-intrusive and robust approach." |
Dmitri Gribenko | d2bbdcf | 2014-03-07 09:06:12 +0000 | [diff] [blame] | 81 | |
| 82 | `<https://github.com/AlexDenisov/ToyClangPlugin>`_ |
| 83 | "The simplest Clang plugin implementing a semantic check for Objective-C. |
| 84 | This example shows how to use the ``DiagnosticsEngine`` (emit warnings, |
| 85 | errors, fixit hints). See also `<http://l.rw.rw/clang_plugin>`_ for |
| 86 | step-by-step instructions." |
| 87 | |
Kevin Funk | 83143a8 | 2017-02-24 08:29:46 +0000 | [diff] [blame] | 88 | `<https://phabricator.kde.org/source/clazy>`_ |
| 89 | "clazy is a compiler plugin which allows clang to understand Qt semantics. |
| 90 | You get more than 50 Qt related compiler warnings, ranging from unneeded |
| 91 | memory allocations to misusage of API, including fix-its for automatic |
| 92 | refactoring." |
Stephan Bergmann | b6ae528 | 2017-03-22 08:45:49 +0000 | [diff] [blame] | 93 | |
| 94 | `<https://gerrit.libreoffice.org/gitweb?p=core.git;a=blob_plain;f=compilerplugins/README;hb=HEAD>`_ |
| 95 | "LibreOffice uses a Clang plugin infrastructure to check during the build |
| 96 | various things, some more, some less specific to the LibreOffice source code. |
| 97 | There are currently around 50 such checkers, from flagging C-style casts and |
| 98 | uses of reserved identifiers to ensuring that code adheres to lifecycle |
| 99 | protocols for certain LibreOffice-specific classes. They may serve as |
| 100 | examples for writing RecursiveASTVisitor-based plugins." |