一句话:设计并实现 SugarC,将真实 C 预处理器的编译期可变性去糖为纯 C 的运行时可变性,并同步类型检查。
可配置 C 软件广泛使用预处理器表达编译期可变性,这给变异性感知分析带来挑战。SugarC 的目标是把同时使用 C 与预处理器的真实代码转换为纯 C,用运行时可变性替代预处理器的编译期可变性。该工具在 C 形式语法规范上增加翻译规则,在去糖过程中同步做类型检查,并针对真实预处理器用法引入多项优化。作者构建了含 108 个人工程序的 DesugarBench 进行评测,显示 SugarC 比两个已有去糖工具支持更多语言特性;在三个真实可配置 C 软件上,它在 813 个文件中成功去糖 774 个,最坏耗时约十分钟,95% 的 C 文件在两分钟内完成。
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.