[PATCH] D17861: [OpenCL] Accept __attribute__((nosvm))

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 28 06:29:56 PDT 2016


aaron.ballman added inline comments.

================
Comment at: include/clang/Basic/Attr.td:701
@@ -699,1 +700,3 @@
 
+def OpenCLNoSVM : Attr {
+  let Spellings = [GNU<"nosvm">];
----------------
yaxunl wrote:
> aaron.ballman wrote:
> > yaxunl wrote:
> > > aaron.ballman wrote:
> > > > Since the attribute is ignored by clang, you should inherit from IgnoredAttr.
> > > I tried that from beginning. If I inherit from IgnoredAttr, it seems to be ignored by the parser and won't reach the sema check part, and I cannot emit error msg based on OpenCL version.
> > Ah. so it isn't *totally* ignored. Okay, in that case, you should set ASTNode = 0 and SemaHandler = 0.
> If I set ASTNode = 0 and SemaHandler = 0, tablegen will not generate an id AT_OpenCLNoSVM to identify this attribute, and I cannot diagnose its invalid usage in SemaDeclAttr.cpp due to that. Then it seems the only viable place to diagnose its invalid usage is in Parser::ParseGNUAttributes. However currently Parser::ParseGNUAttributes only does generic processing of GNU attributes and does not diagnose specific attribute. Since there is no id for NoSVM attribute, I have to diagnose based on its name string.
> 
> Do we really want to do this?
Oh! I forgot that setting SemaHandler to 0 means that the AttributeList enumeration won't get an entry for the attribute, so we probably diagnose it as being unknown rather than getting to the language option checking. Ugh, sorry for the noise, you will want SemaHandler = 1 still (which it is by default, so no need to explicitly specify that), but ASTNode = 0 since we don't generate any AST information for the attribute.


Repository:
  rL LLVM

http://reviews.llvm.org/D17861





More information about the cfe-commits mailing list