Back To Schedule

Large Scale Automated Refactoring Across Translation Unit Boundaries

11:00 - 11:45 Tuesday 9th May 2023 MT Bethe Hall
Intermediate
Advanced
Tooling/Utilities

Refactoring thousands of structs across orders of magnitude more files is difficult even using automated tools. When the edits can affect any other file, it seems impossible. Normally we focus on edits that can be performed within a single translation unit. This is a practical concern: we simply cannot fit every abstract syntax tree (AST) in memory simultaneously. In contrast, we explore an approach to propagate knowledge across translation units after edit generation. More specifically, this examines converting an old macro library similar to BOOST_FUSION_DEFINE_STRUCT into a new mixin template library with subtly diverging API provisions.

We follow the entire process from an initial problem statement, to the creation of AST based code rewritings using Clang, the simultaneous generation of metadata, aggregation of edits via Google Flume, analysis of the proposed edits and metadata, and the final generation of patches. Special attention is paid to how a Clang refactoring tool is built and the metadata design that enables effective subsequent analysis. We conclude with a reflection on the practical lessons from applying this pipeline to real code.

View Slides

Zie Weaver

Software EngineerGoogle

Zie Weaver graduated from the University of Pittsburgh and has been working at Google ever since.  Presently, she works on the C++ Core Libraries team where she maintains decades old code at the bottom of the software stack and performs large scale refactorings pursuant to this maintenance.