[PATCH] D16040: [OpenCL] Refine OpenCLImageAccessAttr to OpenCLAccessAttr

Xiuli PAN via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 17 18:49:01 PST 2016


pxli168 added a comment.

Hi Anastasia,
It seems the access qualifier attribute may need to be handled like the you have mentioned in clang-commit that to be in type.
What is you opinion? I can write a patch for that too.

Thanks


================
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);
+    }
+  }
 
----------------
aaron.ballman wrote:
> pxli168 wrote:
> > 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.
> You should look into why it does not make its way into distributeTypeAttrsFromDeclarator(); as it stands, I am uncomfortable with the current approach.
Hi Aaron,
It seems that OpenCL type that use this attribute did not go through this path, and I will find a way to handle this.

Thanks


http://reviews.llvm.org/D16040





More information about the cfe-commits mailing list