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++ |
| CodeChecker | Platform for running static analysers and managing code defects |
| Uncrustify | Source code beautifer |
| Infer | Static analyser that detects bugs in Java, C and C++ code |
| Include What You Use | Source analysis tool for C and C++ projects built on Clang |
| Cppcheck | Static analysis tool for C/C++ code |
| flawfinder | Scans C and C++ source code for potential security weaknesses |
| clazy | Qt-focused static analyser that catches common C++ mistakes |
| ClangFormat | Code formatting tool |
| Clang-Tidy | Clang-based C++ “linter” tool |
| Smatch | Static analysis tool for finding defects in C code |
| Coccinelle | Semantic patching tool for analysing and transforming C code |
Read our verdict in the software roundup.
LinuxLinks helps you discover the best free and open source software for Linux. Explore our extensive collection of recommended applications, including alternatives to popular proprietary software.We also publish software reviews, Linux tutorials, hardware reviews, free programming books and articles covering the wider open source community. Browse our Linux resources to discover more. Know a useful free and open source Linux application we haven't covered? Suggest a program for inclusion. Has your software been featured on LinuxLinks? Display one of our Featured on LinuxLinks badges on your website or GitHub README. |


Please read our Comment Policy before commenting.