[PATCH] D16040: [OpenCL] Refine OpenCLImageAccessAttr to OpenCLAccessAttr
Xiuli PAN via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 15 23:48:11 PST 2016
pxli168 requested a review of this revision.
pxli168 added a comment.
Need to refine access qualifier with pipe type.
================
Comment at: lib/Sema/SemaDeclAttr.cpp:5052
@@ +5051,3 @@
+ if (D->hasAttr<OpenCLAccessAttr>()) {
+ S.Diag(D->getLocation(), diag::err_opencl_multiple_access_qualifiers)
+ << D->getSourceRange();
----------------
aaron.ballman wrote:
> This should be pointing to the attribute, not the declaration, shouldn't it?
In this case there will be two attributes, so I think it should just point to the declaration.
================
Comment at: lib/Sema/SemaDeclAttr.cpp:5804-5816
@@ -5768,9 +5803,15 @@
- // Walk the declarator structure, applying decl attributes that were in a type
- // position to the decl itself. This handles cases like:
- // int *__attr__(x)** D;
- // when X is a decl attribute.
- for (unsigned i = 0, e = PD.getNumTypeObjects(); i != e; ++i)
- if (const AttributeList *Attrs = PD.getTypeObject(i).getAttrs())
- ProcessDeclAttributeList(S, D, Attrs, /*IncludeCXX11Attributes=*/false);
+ // Skip pipe type, otherwise it will be processed twice with its element type
+ const ParmVarDecl *PDecl = llvm::dyn_cast<ParmVarDecl>(D);
+ if (!PDecl ||
+ !PDecl->getType().getCanonicalType().getTypePtr()->isPipeType()) {
+ // Walk the declarator structure, applying decl attributes that were in a
+ // type position to the decl itself. This handles cases like:
+ // int *__attr__(x)** D;
+ // when X is a decl attribute.
+ for (unsigned i = 0, e = PD.getNumTypeObjects(); i != e; ++i) {
+ if (const AttributeList *Attrs = PD.getTypeObject(i).getAttrs())
+ ProcessDeclAttributeList(S, D, Attrs, /*IncludeCXX11Attributes=*/false);
+ }
+ }
----------------
I think this attribute one that need to be slid on the declaration. Now I just handle this in ProcessDeclAttributes, with
```
const ParmVarDecl *PDecl = llvm::dyn_cast<ParmVarDecl>(D);
if (!PDecl ||
!PDecl->getType().getCanonicalType().getTypePtr()->isPipeType()) {
```
And I tried to handle it in distributeTypeAttrsFromDeclarator but it seems this attribute does not go through that path and I am still working on how to place this check.
http://reviews.llvm.org/D16040
More information about the cfe-commits
mailing list