Coccinelle is a program matching and transformation engine for C source code. It lets developers describe recurring code patterns and apply transformations across large codebases.
At the heart of Coccinelle is the Semantic Patch Language, usually abbreviated to SmPL. Semantic patches describe changes in a form that abstracts away many insignificant differences between individual pieces of source code. This makes it possible to find related coding patterns even when variable names, expressions or surrounding code differ.
Coccinelle has particularly strong links with Linux kernel development, where it is used both to automate widespread API changes and to identify recurring programming errors. Its spatch utility applies semantic patches to source code and can either report matches or generate modified code.
This is free and open source software.
Key Features
- Matches and transforms C source code.
- Provides the Semantic Patch Language.
- Finds structurally similar code despite syntactic differences.
- Supports source-to-source transformations.
- Can perform large-scale automated refactoring.
- Identifies recurring programming patterns and defects.
- Supports metavariables for matching varying source constructs.
- Understands control-flow relationships when matching code.
- Provides the `spatch` command-line utility.
- Widely used for maintaining and analysing Linux kernel code.
Website: coccinelle.gitlabpages.inria.fr/website
Support:
Developer: Julia Lawall, Yoann Padioleau, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
License: GNU General Public License v2.0
Coccinelle is written primarily in OCaml. Learn OCaml with our recommended free books and free tutorials.
Related Software
| C and C++ Linters | |
|---|---|
| OCLint | Static code analysis tool for improving quality and reducing defects |
| cpplint | Static code checker for C++ |
| Uncrustify | Source code beautifer |
| Include What You Use | Source analysis tool for C and C++ projects built on Clang |
| Cppcheck | Static analysis tool for C/C++ code |
| ClangFormat | Code formatting tool |
| Clang-Tidy | Clang-based C++ “linter” tool |
Read our verdict in the software roundup.
Explore our carefully curated directory of recommended free and open source software, covering every major software category.The directory forms part of our extensive collection of articles for Linux enthusiasts. It includes hundreds of detailed reviews, together with free and open source alternatives to proprietary software from companies such as Google, Microsoft, Apple, Adobe, IBM, Cisco, Oracle, and Autodesk. LinuxLinks also covers interesting projects worth exploring, Linux-compatible hardware, free programming books and tutorials, and much more. Know a useful free and open source Linux application that we haven’t covered? Tell us about it using our submission form. |


Please read our Comment Policy before commenting.