This is the template version of https://reviews.llvm.org/D114251. This patch introduces a new template name kind (UsingTemplateName). The UsingTemplateName stores the found using-shadow decl (and underlying template can be retrieved from the using-shadow decl). With the new template name, we can be able to find the using decl that a template typeloc (e.g. TemplateSpecializationTypeLoc) found its underlying template, which is useful for tooling use cases (include cleaner etc). This patch merely focuses on adding the node to the AST. Next steps: - support using-decl in qualified template name; - update the clangd and other tools to use this new node; - add ast matchers for matching different kinds of template names; Differential Revision: https://reviews.llvm.org/D123127
36 lines
1.3 KiB
C++
36 lines
1.3 KiB
C++
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++17 -ast-dump %s | FileCheck -strict-whitespace %s
|
|
|
|
// Tests to verify we construct correct using template names.
|
|
// TemplateNames are not dumped, so the sugar here isn't obvious. However
|
|
// the "using" on the TemplateSpecializationTypes shows that the
|
|
// UsingTemplateName is present.
|
|
namespace ns {
|
|
template<typename T> class S {
|
|
public:
|
|
S(T);
|
|
};
|
|
}
|
|
using ns::S;
|
|
|
|
// TemplateName in TemplateSpecializationType.
|
|
template<typename T>
|
|
using A = S<T>;
|
|
// CHECK: TypeAliasDecl
|
|
// CHECK-NEXT: `-TemplateSpecializationType {{.*}} 'S<T>' dependent using S
|
|
|
|
// TemplateName in TemplateArgument.
|
|
template <template <typename> class T> class X {};
|
|
using B = X<S>;
|
|
// CHECK: TypeAliasDecl
|
|
// CHECK-NEXT: `-TemplateSpecializationType {{.*}} 'X<ns::S>' sugar X
|
|
// CHECK-NEXT: |-TemplateArgument using template S
|
|
// CHECK-NEXT: `-RecordType {{.*}} 'X<ns::S>'
|
|
// CHECK-NEXT: `-ClassTemplateSpecialization {{.*}} 'X'
|
|
|
|
// TemplateName in DeducedTemplateSpecializationType.
|
|
S DeducedTemplateSpecializationT(123);
|
|
using C = decltype(DeducedTemplateSpecializationT);
|
|
// CHECK: DecltypeType {{.*}}
|
|
// CHECK-NEXT: |-DeclRefExpr {{.*}}
|
|
// CHECK-NEXT: `-DeducedTemplateSpecializationType {{.*}} 'ns::S<int>' sugar using
|