Matheus Izvekov <mizvekov@gmail.com>
C++ Template instantiations are performed only considering the canonical template arguments.
Any accesses through template specializations, as it currently stands, lose any non-structural parts of the template arguments.
Resugar types and expressions accessed through template specializations, replacing the canonical types therein with the sugared types as written in the arguments of the specializations.
In simplest terms, with an example, we want this to work:
template<class T> struct foo { using type = T; }; struct Baz {}; using Bar [[gnu::aligned(64)]] = Baz; using type = typename foo<Bar>::type; // Clang as it stands will fail below assert // as the foo template will only be instantiated // with the structural part of the argument, // which the Bar alias is not. // So it only sees Baz, the aligned attribute is never seen. static_assert(alignof(type) == 64);
Got up to speed with development environment.
Frontloading some of the work, starting with a simpler implementation which resugars eagerly instead of lazily as initially proposed here.
Investigate design approaches. Deliverable: A concise technical document sent as a RFC to clang’s developer mailing lists.
Improve the representation of type information of a ClassTemplateSpecializationDecl. Deliverable: Design a new type in clang: MemberSugarType.
ClassTemplateSpecializationDecl
MemberSugarType
Improve the representation of type information of a ClassTemplateSpecializationDecl. Deliverable: Connect the MemberSugarType to it.
Implement a single-step desugaring based on desguaring a MemberSugarType wrapped around a FunctionProtoType. Deliverable: The ability to push the member sugar onto the return type and parameter types of the type.
FunctionProtoType
Implementing a MemberSugarType wrapped around a RecordType representing a member of the type tracked by a MemberSugarType would form an ElaboratedType describing the name of that member as a member of the sugared type. Deliverable: The ability to push the member sugar via ElaboratedType.
RecordType
ElaboratedType
SubstTemplateTypeParmType
Foo
TemplateSpecializationType
x.front()
Buffer week
Demonstrate the usefulness of the diagnostic and also preserving of type sugar in the AST for I/O purposes (via the CERN Data Analysis Project ROOT). Deliverable: Remove the ROOT patch / hack.