Fast Constraint Synthesis for C++ Function Templates
This program is tentative and subject to change.
C++ templates are a powerful feature for generic programming and compile-time computations. It is well known that C++ compilers often emit overly verbose template error messages, and even short error messages often involve unnecessary and confusing implementation details, which are difficult for developers to read and understand. To address this problem, C++20 introduced \emph{constraints and concepts}, which impose requirements on template parameters. The new features can define clearer interfaces for templates, and can improve the compiler diagnostics for failed template instantiations. However, manually specifying template constraints can still be a non-trivial task. This task becomes even more challenging when working with legacy C++ projects or with frequent code changes during development.
This paper bridges the gap and proposes the first automatic approach to synthesizing constraints for C++ function templates. Our approach utilizes a lightweight static analysis to analyze the usage patterns within the template body and summarizes them into constraints for each type parameter of the template. The analysis is inter-procedural and uses disjunctions of constraints to model function overloading. We have implemented our approach based on the Clang frontend and evaluated it on two C++ libraries chosen separately from two popular library sets: algorithm from the Standard Template Library (STL) and special_functions from the Boost library, both of which extensively use templates. Our tool can process over $110$k lines of C++ code in less than $1.5$ seconds and synthesize non-trivial constraints for $30$%-$40$% of the function templates. Furthermore, the constraints synthesized for algorithm align well with the standard documentation, and on average, the synthesized constraints can reduce error message lengths by $56.6$% for algorithm and $63.8$% for special_functions.
This program is tentative and subject to change.
Sat 18 OctDisplayed time zone: Perth change
10:30 - 12:15 | |||
10:30 15mTalk | Abstraction Refinement-guided Program Synthesis for Robot Learning from Demonstrations OOPSLA Guofeng Cui Rutgers University, Yuning Wang Rutgers University, Wensen Mao Rutgers University, Yuanlin Duan Rutgers University, He Zhu Rutgers University, USA | ||
10:45 15mTalk | API-guided Dataset Synthesis to Finetune Large Code Models OOPSLA Li Zongjie Hong Kong University of Science and Technology, Daoyuan Wu Lingnan University, Shuai Wang Hong Kong University of Science and Technology, Zhendong Su ETH Zurich | ||
11:00 15mTalk | Fast Constraint Synthesis for C++ Function Templates OOPSLA | ||
11:15 15mTalk | Hambazi: Spatial Coordination Synthesis for Augmented Reality OOPSLA Yi-Zhen Tsai University of California, Riverside, Jiasi Chen University of Michigan, Mohsen Lesani University of California at Santa Cruz | ||
11:30 15mTalk | Inductive Synthesis of Inductive Heap Predicates OOPSLA | ||
11:45 15mTalk | LOUD: Synthesizing Strongest and Weakest Specifications OOPSLA Kanghee Park University of Wisconsin-Madison, Xuanyu Peng University of California, San Diego, Loris D'Antoni University of California at San Diego | ||
12:00 15mTalk | Metamorph: Synthesizing Large Objects from Dafny Specifications OOPSLA Aleksandr Fedchin Tufts University, Alexander Bai New York University, Jeffrey S. Foster Tufts University |