[PATCH] D23086: [OpenCL] Generate concrete struct type for ndrange_t
Yaxun Liu via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 15 12:31:05 PDT 2016
yaxunl added a comment.
In https://reviews.llvm.org/D23086#515506, @Anastasia wrote:
> Surely vendors can re-implement all OpenCL types with an implicit typedef. For example this would just work:
> typedef int queue_t;
> void bar(queue_t q);
> I am afraid we will need to provide some implementation to ndrange_t in Clang itself, otherwise I don't see how it could work. Also it would be good to offer standard functionality without any extra includes just like it worked up to now for all other features.
It will work if we have a way to identify whether a type is ndrange_t type. So far I have suggested to compare the canonical types. Basically when we see a declaration of typedef with name 'ndrange_t', we save its canonical type X to ASTContext. When we need to check if type Y is ndrange_t, we just need to check Y->getCanonicalType() == X.
On the other hand, pre-define ndrange_t in Clang does not solve the problem of how to decide if a type is ndrange_t, since user can define typedefs for ndrange_t, e.g.
typedef ndrange_t my_ndrange_t;
In this case, we still need to check the canonical type.
More information about the cfe-commits