[clang] Qualify non-dependent types of a class template with its declaration (PR #67566)

Vassil Vassilev via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 29 23:18:41 PDT 2023


vgvassilev wrote:

> > > I gave it a quick try, and we would still end up with the same result in our codebase. But, generally, this would not probably be feasible for us as a solution.
> > 
> > 
> > do you have an idea why? Can you show the diff of the changes you made? Is the void specialization not explicit?
> 
> I did a quick test with this:
> 
> ```
> diff --git a/clang/lib/AST/QualTypeNames.cpp b/clang/lib/AST/QualTypeNames.cpp
> index 26aaa96a1dc6..8b882eda83bb 100644
> --- a/clang/lib/AST/QualTypeNames.cpp
> +++ b/clang/lib/AST/QualTypeNames.cpp
> @@ -287,8 +287,13 @@ static NestedNameSpecifier *createNestedNameSpecifierForScopeOf(
>          //
>          // Make the situation is 'useable' but looking a bit odd by
>          // picking a random instance as the declaring context.
> -        if (ClassTempl->spec_begin() != ClassTempl->spec_end()) {
> -          Decl = *(ClassTempl->spec_begin());
> +        auto specialization_iterator = std::find_if(
> +            ClassTempl->spec_begin(), ClassTempl->spec_end(), [](auto a) {
> +              return !a->isExplicitInstantiationOrSpecialization();
> +            });
> +
> +        if (specialization_iterator != ClassTempl->spec_end()) {
> +          Decl = *specialization_iterator;
>            Outer = dyn_cast<NamedDecl>(Decl);
>            OuterNS = dyn_cast<NamespaceDecl>(Decl);
>          }
> ```
> 
> Do please let me know if this is incorrect or if I misunderstood your proposal.
> 
> We do have explicit references to the void specialization in the codebase so it would explain the previous choice. But I'm not aware of why it would be chosen as a non-explicit one too.
> 
> I can try to debug that on Monday if that can be useful. Albeit it might take some time.

You probably need [isExplicitSpecialization](https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html#acd75ba25d34249d2e21ebbecbb2ef70e)()

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


More information about the cfe-commits mailing list