[PATCH] D141826: [WIP][clang][TemplateBase] Add IsDefaulted bit to TemplateArgument

Michael Buch via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 23 01:40:45 PST 2023


Michael137 added a comment.

In D141826#4059088 <https://reviews.llvm.org/D141826#4059088>, @erichkeane wrote:

> In D141826#4059073 <https://reviews.llvm.org/D141826#4059073>, @Michael137 wrote:
>
>> In D141826#4058866 <https://reviews.llvm.org/D141826#4058866>, @erichkeane wrote:
>>
>>> This seems innocuous enough/easy enough to use.  I'd like a comment on the functions at least and types in TemplateBase.h to specify that this is for printing-policy only?  Alternatively (and perhaps MUCH more appreciated) would be to make sure we mark the defaulted during AST generation as well.
>>
>> I'll have a look at doing that
>>
>> Are you suggesting we do the substitution check that the TypePrinter currently does when constructing the specialisation decls? So the TypePrinter simply needs to check the `TemplateArgument::getIsDefaulted`? I like the sound of that.
>>
>> Unfortunately we'd still need the `setIsDefaulted` because of the DWARF limitation in LLDB
>
> Yes, thats my thought.  Of course we'd still need the 'setIsDefaulted', but at least it would be something that coudl be generally useful.

So I've been having a go at this. The latest diff sets the bit when creating `ClassTemplateSpecializationDecl`s. However, we end up having to copy the `ArrayRef<TemplateArgument>` twice (because of the current assumptions that a `TemplateArgumentList` is immutable, which seems like a nice property to maintain). But the double copy does seem iffy.

I also had to add the flag to the `TemplateArgument` tablegen description to support deserialized `ClassTemplateSpecializationDecl`.

I've been playing around with setting the flag at construction of `TemplateArgument`s instead. Not sure how much cleaner that's going to be because so far I've not found a good single point of entry (been looking at CheckTemplateArgumentList <https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaTemplate.cpp#L6004-L6116> in `SemaTemplate`)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141826/new/

https://reviews.llvm.org/D141826



More information about the cfe-commits mailing list