[llvm-branch-commits] [clang] [libcxx] [clang] Preserve Qualifiers and type sugar in TemplateNames (PR #93433)

Ilya Biryukov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue May 28 01:55:29 PDT 2024


================
@@ -9304,7 +9299,8 @@ TemplateName ASTContext::getAssumedTemplateName(DeclarationName Name) const {
 TemplateName ASTContext::getQualifiedTemplateName(NestedNameSpecifier *NNS,
                                                   bool TemplateKeyword,
                                                   TemplateName Template) const {
-  assert(NNS && "Missing nested-name-specifier in qualified template name");
----------------
ilya-biryukov wrote:

Makes total sense, this change to the contract of the class seems very reasonable.
I have also went through all usages and we don't see to have any uses left that don't check for null in return of `getQualifier`.

Could we update the documentation of the class? It currently says (see below) that the name must always be qualified, mentioning that it may also be qualified only with `template` keyword without the nested name specifier.

```cpp
/// Represents a template name that was expressed as a
/// qualified name.
///
/// This kind of template name refers to a template name that was
/// preceded by a nested name specifier, e.g., \c std::vector. Here,
/// the nested name specifier is "std::" and the template name is the
/// declaration for "vector". The QualifiedTemplateName class is only
/// used to provide "sugar" for template names that were expressed
/// with a qualified name, and has no semantic meaning. In this
/// manner, it is to TemplateName what ElaboratedType is to Type,
/// providing extra syntactic sugar for downstream clients.
```

https://github.com/llvm/llvm-project/pull/93433


More information about the llvm-branch-commits mailing list