Apple Contributes SSAF Driver To LLVM Clang For Source Code Transformations

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 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.

Original Source

Read the full article at Phoronix →

KhanList aggregates and links to publicly available news content. We do not host full articles from third-party sources. Always verify important information with original sources.