Anastasia marked an inline comment as done.
Anastasia added inline comments.


================
Comment at: lib/Sema/SemaType.cpp:7421
+      // - template specialization as addr space in template argument doesn't
+      //   affect specialization.
+      (T->isDependentType() && (!T->isPointerType() && !T->isReferenceType() &&
----------------
rjmccall wrote:
> Anastasia wrote:
> > rjmccall wrote:
> > > I don't understand what you're saying here.  Why does inference depend on 
> > > whether the type is a template specialization?  And what does this have 
> > > to do with template arguments?  Also, address spaces in template 
> > > arguments are definitely part of the template argument and affect which 
> > > specialization you're naming.
> > What I am trying to say here is that an address space of a template 
> > argument isn't used as an address space of a template specialization and 
> > therefore we can deduce the address space of a template specialization 
> > since it's not going to be provided during the template instantiation.
> > 
> > Let's say we have specialization `MyClass<T>`. The address space of `T` has 
> > nothing to do with the address space of `MyClass<T>`. They are different. 
> > Therefore if the address space of `MyClass<T>` is not provided explicitly 
> > it is ok to deduce it.
> > 
> > Does it make sense?
> Of course the address space of `T` has nothing to do with the address space 
> of `MyClass<T>`, but that's true of literally every type, and you don't need 
> to add special cases checking for specific type spellings.
> 
> Why don't you just never infer address spaces on dependent types and then 
> infer them as necessary during instantiation?  Why is it important to infer 
> address spaces on any dependent type in the template pattern?
I quite like to keep the inference logic in one place mainly to avoid code 
duplication and simplify the architecture. However, it seems to be just much 
simpler to move the inference of pointee type into template instantiation.

I am thinking about the other cases i.e. non-pointer types and it seems that 
might be much harder to move there because the place we are transforming the 
type doesn't have information of where and how the type is being used. So in 
the future we might end up with inference logic scattered around the 
`TreeTransform` code propagated through `Subst*Type` calls rather than being 
kept in one place like we do here in SemaType. Not sure if you have better 
ideas how we could keep similar architecture in template instantiation too.


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

https://reviews.llvm.org/D64400



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to