Add support for LangOptions.Renderscript + "kernel" attribute.

Change-Id: I75596363b8519ad0a1372a316826050c6be4e922
diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td
index e8e0f35..61e64b2 100644
--- a/include/clang/Basic/Attr.td
+++ b/include/clang/Basic/Attr.td
@@ -256,6 +256,10 @@
   let Spellings = ["opencl_kernel_function"];
 }
 
+def Kernel : Attr {
+  let Spellings = ["kernel"];
+}
+
 def Deprecated : InheritableAttr {
   let Spellings = ["deprecated"];
   let Args = [StringArgument<"Message">];
diff --git a/include/clang/Basic/LangOptions.def b/include/clang/Basic/LangOptions.def
index d2ce7c0..d3ef12f 100644
--- a/include/clang/Basic/LangOptions.def
+++ b/include/clang/Basic/LangOptions.def
@@ -113,6 +113,7 @@
 
 LANGOPT(OpenCL            , 1, 0, "OpenCL")
 LANGOPT(CUDA              , 1, 0, "CUDA")
+LANGOPT(Renderscript      , 1, 0, "Renderscript")
 
 LANGOPT(AssumeSaneOperatorNew , 1, 1, "implicit __attribute__((malloc)) for C++'s new operators")
 BENIGN_LANGOPT(ElideConstructors , 1, 1, "C++ copy constructor elision")
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index 5c6ddd2..3d2ef87 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -2861,6 +2861,14 @@
                                                         S.Context));
 }
 
+static void handleKernelAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+  if (S.LangOpts.Renderscript) {
+    D->addAttr(::new (S.Context) KernelAttr(Attr.getRange(), S.Context));
+  } else {
+    S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << "kernel";
+  }
+}
+
 static void handleConstantAttr(Sema &S, Decl *D, const AttributeList &Attr) {
   if (S.LangOpts.CUDA) {
     // check the attribute arguments.
@@ -3562,6 +3570,7 @@
   case AttributeList::AT_device:      handleDeviceAttr      (S, D, Attr); break;
   case AttributeList::AT_host:        handleHostAttr        (S, D, Attr); break;
   case AttributeList::AT_overloadable:handleOverloadableAttr(S, D, Attr); break;
+  case AttributeList::AT_kernel:      handleKernelAttr      (S, D, Attr); break;
   default:
     break;
   }
@@ -3586,6 +3595,7 @@
   case AttributeList::AT_device:
   case AttributeList::AT_host:
   case AttributeList::AT_overloadable:
+  case AttributeList::AT_kernel:
     // Ignore, this is a non-inheritable attribute, handled
     // by ProcessNonInheritableDeclAttr.
     break;