[PATCH] D155858: Add a concept AST node.

Jens Massberg via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 30 04:07:03 PDT 2023


massberg added inline comments.


================
Comment at: clang/lib/Sema/TreeTransform.h:6824-6836
+      unsigned size = TL.getTypePtr()->getTypeConstraintArguments().size();
+      TemplateArgumentLocInfo *TALI = new TemplateArgumentLocInfo[size];
+      TemplateSpecializationTypeLoc::initializeArgLocs(
+          SemaRef.Context, TL.getTypePtr()->getTypeConstraintArguments(), TALI,
+          SourceLocation());
+      TemplateArgumentLoc *TAL = new TemplateArgumentLoc[size];
+      for (unsigned i = 0; i < size; ++i)
----------------
sammccall wrote:
> massberg wrote:
> > This is very ugly as I have to create the TALI and TAL arrays temporarily to use the existing transformations.
> > Is there a better way to do that?
> > Moreover, is this the correct place for the transformation? This is necessary as the passed `AutoTypeLoc` doesn't have an attached `ConceptReference` even if it is constrained. Has the `ConceptReferenec`of the original `AutoTypeLoc` be added somewhere earlier?
> If I'm understanding the situation right...
> the AutoTypeLoc in the template should have a ConceptReference, since the `auto` is constrained.
> This seems like a bug to be fixed elsewhere, and then this `else` becomes dead.
> 
> Do you have a minimal example?
A minimal example:

```
template <typename T> concept C = true;

template<C auto M>
void foo2() {}

int main(void) {
  foo2<1>();
}
```

As discussed, a `ConceptReference` will now be created in `initializeLocal` so that it is guaranteed that we have it available here. I have added an assert to verify that there is an `ConceptReference` in case that the `AutoType` is constrained.
If we do not set the `ConceptReference` in `initializeLocal` then there are already several tests that fail as the `assert` isn't satisifed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155858



More information about the cfe-commits mailing list