r272438 - Revise RenderScript attribute declaration

Pirama Arumuga Nainar via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 10 14:51:18 PDT 2016


Author: pirama
Date: Fri Jun 10 16:51:18 2016
New Revision: 272438

URL: http://llvm.org/viewvc/llvm-project?rev=272438&view=rev
Log:
Revise RenderScript attribute declaration

Summary:
Address post-patch comments to r272342.

- Rename the 'kernel' attribute's name
- Idiomatically restrict the attribute to the 'RenderScript' LangOpt.

Reviewers: aaron.ballman, rsmith

Subscribers: cfe-commits, srhines

Differential Revision: http://reviews.llvm.org/D21240

Modified:
    cfe/trunk/include/clang/Basic/Attr.td
    cfe/trunk/lib/Sema/SemaDeclAttr.cpp
    cfe/trunk/test/Sema/renderscript.rs

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=272438&r1=272437&r2=272438&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Fri Jun 10 16:51:18 2016
@@ -240,6 +240,7 @@ def Borland : LangOpt<"Borland">;
 def CUDA : LangOpt<"CUDA">;
 def COnly : LangOpt<"CPlusPlus", 1>;
 def OpenCL : LangOpt<"OpenCL">;
+def RenderScript : LangOpt<"RenderScript">;
 
 // Defines targets for target-specific attributes. The list of strings should
 // specify architectures for which the target applies, based off the ArchType
@@ -728,10 +729,11 @@ def OpenCLNoSVM : Attr {
   let ASTNode = 0;
 }
 
-def Kernel : Attr {
+def RenderScriptKernel : Attr {
   let Spellings = [GNU<"kernel">];
   let Subjects = SubjectList<[Function]>;
   let Documentation = [Undocumented];
+  let LangOpts = [RenderScript];
 }
 
 def Deprecated : InheritableAttr {

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=272438&r1=272437&r2=272438&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri Jun 10 16:51:18 2016
@@ -4185,17 +4185,6 @@ static void handleTypeTagForDatatypeAttr
                                     Attr.getAttributeSpellingListIndex()));
 }
 
-static void handleKernelAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  if (S.LangOpts.RenderScript) {
-    D->addAttr(::new (S.Context)
-               KernelAttr(Attr.getRange(), S.Context,
-                          Attr.getAttributeSpellingListIndex()));
-  } else {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << "kernel";
-  }
-}
-
-
 //===----------------------------------------------------------------------===//
 // Checker-specific attribute handlers.
 //===----------------------------------------------------------------------===//
@@ -5925,8 +5914,8 @@ static void ProcessDeclAttribute(Sema &S
     handleTypeTagForDatatypeAttr(S, D, Attr);
     break;
 
-  case AttributeList::AT_Kernel:
-    handleKernelAttr(S, D, Attr);
+  case AttributeList::AT_RenderScriptKernel:
+    handleSimpleAttribute<RenderScriptKernelAttr>(S, D, Attr);
     break;
   }
 }

Modified: cfe/trunk/test/Sema/renderscript.rs
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/renderscript.rs?rev=272438&r1=272437&r2=272438&view=diff
==============================================================================
--- cfe/trunk/test/Sema/renderscript.rs (original)
+++ cfe/trunk/test/Sema/renderscript.rs Fri Jun 10 16:51:18 2016
@@ -2,11 +2,15 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -x c %s
 
 #ifndef __RENDERSCRIPT__
-// expected-warning at +2 {{kernel attribute ignored}}
+// expected-warning at +2 {{'kernel' attribute ignored}}
 #endif
-void __attribute__((kernel)) kernel();
+void __attribute__((kernel)) kernel() {}
 
-// expected-warning at +1 {{'kernel' attribute only applies to functions}}
+#ifndef __RENDERSCRIPT__
+// expected-warning at +4 {{'kernel' attribute ignored}}
+#else
+// expected-warning at +2 {{'kernel' attribute only applies to functions}}
+#endif
 int __attribute__((kernel)) global;
 
 #ifndef __RENDERSCRIPT__




More information about the cfe-commits mailing list