Implement missing C++26 features in Clang
Introduction
This project proposes a candidate-driven program to complete Clang’s support for
selected C++26-era language papers and closely related C proposals. The
project provides a vehicle for applicants to propose a standards paper that is
not yet implemented in Clang and then implement that paper within the scope of
the project.
Mentors: Vassil Vassilev, Aaron Jomy
Overview
The C and C++ Working Groups proposed several papers for different standards
of the languages to introduce new features, 2 of which are the if declaration
in C2y and CTAD alias templates in C++20. The if declaration proposes a
C++-style if statement with a declaration support; while the
CTAD alias templates propose a way to simplify the use of alias templates to
make CTAD useful for all aspects of C++. The goal of this proposal is to
complete the implementation of these features in Clang.
Benefits to Community
if declaration in C2y
This feature makes C code easier to read and write. It lets programmers
declare a variable inside an if statement, so the variable is only used where it
is needed. This reduces mistakes and keeps code cleaner. Adding it to Clang
helps developers use modern C features earlier and keeps Clang up to date
with the C2y standard. There’s nearly nobody working on C2y features in
Clang, so this will be a step forward for C support in Clang.
CTAD for alias templates in C++20
This feature lets the compiler automatically figure out template types even when
using alias templates. Today, this often fails or needs extra code, which is
confusing. Supporting it in Clang makes code shorter, simpler, and more
consistent with how normal templates already work. It also improves
compatibility with the C++20 standard and other compilers.
Goals
- Fully support and implement the if declaration feature in
ClangforC2ywithout affecting existing functionality and performance. - Extend the existing support for CTAD alias templates in
Clangto support as many cases and contexts as possible as a stretch goal.