SugarC: Scalable Desugaring of Real-World Preprocessor Usage into Pure C
Zach Patterson, Zenong Zhang, Brent Pappas, Shiyi Wei, Paul Gazzillo
Abstract
Variability-aware analysis is critical for ensuring the quality of configurable C software. An important step toward the development of variability-aware analysis at scale is to transform real-world C software that uses both C and preprocessor into pure C code, by replacing the preprocessor's compile-time variability with C's runtime-variability. In this work, we design and implement a desugaring tool, SugarC, that transforms away real-world preprocessor usage. SugarC augments C's formal grammar specification with translation rules, performs simultaneous type checking during desugaring, and introduces numerous optimizations to address challenges that appear in real-world preprocessor usage. The experiments on DesugarBench, a benchmark consisting of 108 manually-created programs, show that SugarC supports many more language features than two existing desugaring tools. When applied on three real-world configurable C software, SugarC desugared 774 out of 813 files in the three programs, taking at most ten minutes in the worst case and less than two minutes for 95% of the C files.
Ask about this paper
Ask your agent about it.
Lune has read the top-tier papers around this one, so every answer names the papers it rests on.
Your agent calls
Lunesearch_papers
Free to start. No credit card required.
Terminal
Install the CLIlune papers get 94c681fe-a313-445e-a28e-d0dd30958705Cited by top-tier papers1
Ask how each one uses itRelated papers
- On the Expressive Power of Languages for Static VariabilityPaul Maximilian Bittner, Alexander Schultheiß, Benjamin Moosherr, Jeffrey M. Young et al.OOPSLA 2024 · 1 citation
- Hayroll: A Modular Wrapper for Translating C Macros and Conditional Compilation to RustHaoran Peng, Baris Kasikci, Gilbert Louis Bernstein, Michael D. ErnstPLDI 2026 · 1 citation
- Automatic and efficient variability-aware lifting of functional programsRamy Shahin, Marsha ChechikOOPSLA 2020 · 18 citations
- One down, 699 to go: or, synthesising compositional desugaringsSándor Bartha, James Cheney, Vaishak BelleOOPSLA 2021 · 2 citations
- Semantic Analysis of Macro Usage for PortabilityBrent Pappas, Paul GazzilloICSE 2024 · 2 citations
