[PATCH] D64400: [OpenCL][PR42390] Deduce addr space for templ specialization

Anastasia Stulova via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 10 09:46:23 PDT 2019


Anastasia marked 2 inline comments as done and 2 inline comments as done.
Anastasia added inline comments.


================
Comment at: include/clang/AST/Type.h:6512
+inline bool Type::isTemplateSpecializationType() const {
+  return isa<TemplateSpecializationType>(this);
+}
----------------
rjmccall wrote:
> This is a sugar type.  What are you trying to do?
I just need a helper function to identify this type in the addr space deduction logic below. Do you think we shouldn't expose it as interface? 

In fact I am now adding `isInjectedClassNameType` for the same reason to cover another similar test case.


================
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:
> 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?


================
Comment at: lib/Sema/SemaType.cpp:7421
+      // - template specialization as addr space in template argument doesn't
+      //   affect specialization.
+      (T->isDependentType() &&
----------------
If you think it's reasonable the same would apply to `InjectedClassNameType`.


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

https://reviews.llvm.org/D64400





More information about the cfe-commits mailing list