Add support for the Microsoft uuid attribute:

example:
struct __declspec(uuid("6d5140c1-7436-11ce-8034-00aa006009fa"))
test { };


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122173 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td
index afd4763..cd5dc21 100644
--- a/include/clang/Basic/Attr.td
+++ b/include/clang/Basic/Attr.td
@@ -422,6 +422,12 @@
   let Spellings = ["used"];
 }
 
+def Uuid : Attr {
+  let Spellings = ["uuid"];
+  let Args = [StringArgument<"Guid">];
+  let Subjects = [CXXRecord];
+}
+
 def Visibility : Attr {
   let Spellings = ["visibility"];
   let Args = [EnumArgument<"Visibility", "VisibilityType",
diff --git a/include/clang/Sema/AttributeList.h b/include/clang/Sema/AttributeList.h
index d524861..69170fa 100644
--- a/include/clang/Sema/AttributeList.h
+++ b/include/clang/Sema/AttributeList.h
@@ -148,6 +148,7 @@
     AT_unavailable,
     AT_unused,
     AT_used,
+    AT_uuid,
     AT_vecreturn,     // PS3 PPU-specific.
     AT_vector_size,
     AT_visibility,
diff --git a/lib/Sema/AttributeList.cpp b/lib/Sema/AttributeList.cpp
index 789c17b..6aa9690 100644
--- a/lib/Sema/AttributeList.cpp
+++ b/lib/Sema/AttributeList.cpp
@@ -133,5 +133,6 @@
     .Case("launch_bounds", AT_launch_bounds)
     .Case("common", AT_common)
     .Case("nocommon", AT_nocommon)
+    .Case("uuid", AT_uuid)
     .Default(UnknownAttribute);
 }
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index e9f885e..b0e022f 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -2516,7 +2516,29 @@
 
 static bool isKnownDeclSpecAttr(const AttributeList &Attr) {
   return Attr.getKind() == AttributeList::AT_dllimport ||
-         Attr.getKind() == AttributeList::AT_dllexport;
+         Attr.getKind() == AttributeList::AT_dllexport ||
+         Attr.getKind() == AttributeList::AT_uuid;
+}
+
+//===----------------------------------------------------------------------===//
+// Microsoft specific attribute handlers.
+//===----------------------------------------------------------------------===//
+
+static void HandleUuidAttr(Decl *d, const AttributeList &Attr, Sema &S) {
+  if (S.LangOpts.Microsoft || S.LangOpts.Borland) {
+    // check the attribute arguments.
+    if (Attr.getNumArgs() != 1) {
+      S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 1;
+      return;
+    }
+    Expr *Arg = Attr.getArg(0);
+    StringLiteral *Str = dyn_cast<StringLiteral>(Arg);
+
+    d->addAttr(::new (S.Context) UuidAttr(Attr.getLoc(), S.Context, 
+                                          Str->getString()));
+  } else {
+    S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << "uuid";
+  }
 }
 
 //===----------------------------------------------------------------------===//
@@ -2646,6 +2668,9 @@
   case AttributeList::AT_pascal:
     HandleCallConvAttr(D, Attr, S);
     break;
+  case AttributeList::AT_uuid:
+    HandleUuidAttr(D, Attr, S);
+    break;
   default:
     // Ask target about the attribute.
     const TargetAttributesSema &TargetAttrs = S.getTargetAttributesSema();