News: 0001663692

  ARM Give a man a fire and he's warm for a day, but set fire to him and he's warm for the rest of his life (Terry Pratchett, Jingo)

Apple Contributes SSAF Driver To LLVM Clang For Source Code Transformations

([LLVM] 3 Hours Ago clang-ssaf-driver)


Apple compiler engineers have contributed to upstream LLVM/Clang today a Scalable Static Analysis Framework (SSAF) driver for whole-program based analysis and source-to-source code transformations.

Upstreamed to LLVM Git today was the clang-ssaf-driver for performing source transformations on whole projects as it builds and then presenting the results. It is able to generate a patch in the end for the auto-generated source transformations in addition to the transformation report.

Clang SSAF is able to add additional transformation rules and one of the first is cpp-bounded-buffers for rewriting C++ raw pointers and arrays that needs bounds into using bounded_ptr and bounded_array.

Apple's Jan Korous explained in the now-merged [1]pull request :

"Add a tool that runs a source transformation over a project as it builds and presents the result. It knows which summaries and which whole-program analysis each transformation needs, so a user names only the transformation and the build command; cpp-bounded-buffers is the first. It drives projects built with make through clang-ssaf-orchestrator-make.

The driver writes the link unit's source edits as a patch, and prints the transformation report the way a compiler prints diagnostics as well as writing it as SARIF. A merge resolves only the conflicts among its own inputs, so an edit that overlaps a reported conflict is left out of the patch. With --apply the driver also applies the edits with clang-apply-replacements, which it looks for before the build, and checks that the sources end up as the patch shows them.

This is a generalization of a tool that we proposed earlier - clang-reforge. We want to build a general-purpose analysis and transformation driver decoupled from the specifics."

Look for the clang-ssaf-driver in LLVM 24 coming out next spring.



[1] https://github.com/llvm/llvm-project/pull/231999



* TwingyAFK is shopping for 17" flat panel
* aav sells TwingyAFK a piece of plywood