[clang] [Clang] Fix crash when type-name is combined with class specifier in template argument (PR #191689)
Oliver Hunt via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 20 12:56:56 PDT 2026
ojhunt wrote:
> I think if the QualifierLoc exists, it must match what's on the type so we could at least assert on that.
>
> A similar assertion is possible for the elaborated keyword case: we could check the source location actually points to the keyword corresponding to it.
>
> Then if the type doesn't have a qualifier, we can simply ignore it. That would mirror what's currently done for the elaborated keyword case.
Right, that's what I meant, an early `if (!TL.hasQualifier()) return;` seems like it would fix this issue, I was just worried that it might be possible to construct a similar problem where a qualifier is present. I'm just unsure how - I think the parsing diverges from a path that can hit this once you have anything other than a single ident qualifier.
>
> Also, the problem probably exists for all other qualifiable types, not just TagDecls.
Right, i couldn't work out how to trigger such a fault though. Basically we need
```
InvalidQualifier SomeQualifiableType
```
but I can only get things to go wrong for an elaborated type, because I _think_ from an AST construction we need a syntax like
```
Identifier1 Identifier2 Scoped::Name
```
Where Identifier1 resolves to something that can be qualified (so we try to shove "Scope::" onto it), but Identifier2 needs to be syntactically valid for a typename/reference without itself being a qualifier.
I'm not sure what things other than a tagdecl can be referenced as a single identifier while still be potentially qualified, and I can't work out something other than an elaborated type for `Identifier2 Scoped::Name`
https://github.com/llvm/llvm-project/pull/191689
More information about the cfe-commits
mailing list