Published December 12, 2025 | Version v1

Introduction to Semantic Patching of C and C++ Programs with Coccinelle

  • 1. ROR icon Leibniz Supercomputing Centre

Description

The maintenance of a large software project can be very demanding. External factors like evolving third-party software library APIs, or constantly changing hardware platforms might require significant code adaptions for the code to run efficiently, or to run at all. Failure in coping with this can lead to obsolescence, loss of performance, incompatibility, vendor lock-inbugs.

Have you ever wondered how to detect and manipulate specified C/C++ code constructs, be it for code analysis, or better, to restructure an arbitrarily large codebase according to a specified, non-trivial `pattern', without writing a source-to-source translator yourself, but using an existing programmable one?

In this training we introduce you to a tool to do exactly this: match and restructure code in a programmatic, formal way.

After this training, you shall be able to write your own code transformations, be it for a refactoring, performance improvement, paving the way to an experimental fork, or for debug/analysis reasons.

The training will also show how to analyse code looking for interesting patterns (e.g. bugs), integrate your Python scripts to achieve the custom transformations you need, and leverage Coccinelle's increasing C++ support.
 
Special mention will go to performance-oriented transformations, of interest of HPC practitioners.

Files

coccinelle_training_20251212.pdf

Files (909.3 kB)

Name Size Download all
md5:f8202057359144580b1c8e9bc3267c47
909.3 kB Preview Download

Additional details

Related works

Cites
Conference paper: 10.1007/978-3-030-90539-2_15 (DOI)
Preprint: https://hal.inria.fr/hal-03266521 (URL)
Preprint: 10.48550/arXiv.2503.20868 (DOI)
Conference paper: 10.1109/IPDPSW66978.2025.00030 (DOI)
Obsoletes
Lesson: 10.5281/zenodo.14728519 (DOI)

Dates

Available
2025-12-12
Presented at LRZ

Software

Repository URL
https://github.com/coccinelle/coccinelle
Programming language
SmPL , OCaml , C , C++
Development Status
Active