Coccinelle – semantic program matching and transformation

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
OCLintStatic code analysis tool for improving quality and reducing defects
cpplintStatic code checker for C++
CodeCheckerPlatform for running static analysers and managing code defects
UncrustifySource code beautifer
InferStatic analyser that detects bugs in Java, C and C++ code
Include What You UseSource analysis tool for C and C++ projects built on Clang
CppcheckStatic analysis tool for C/C++ code
flawfinderScans C and C++ source code for potential security weaknesses
clazyQt-focused static analyser that catches common C++ mistakes
ClangFormatCode formatting tool
Clang-TidyClang-based C++ “linter” tool
SmatchStatic analysis tool for finding defects in C code
CoccinelleSemantic patching tool for analysing and transforming C code

Read our verdict in the software roundup.


Best Free and Open Source Software 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.
Subscribe

Please read our Comment Policy before commenting.

Notify of
guest
0 Comments
Oldest
Newest Most Voted