aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFrancois Pichet <pichet2000@gmail.com>2010-12-19 06:50:37 +0000
committerFrancois Pichet <pichet2000@gmail.com>2010-12-19 06:50:37 +0000
commit11542141e385859df6b4f1a8f1f01856ad193b5b (patch)
tree5cb0f87600d25ce71441a4ab44e4c453af863294 /lib
parente6a365d772a6b455f1e23ac9ae5f40d65a55a18c (diff)
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
Diffstat (limited to 'lib')
-rw-r--r--lib/Sema/AttributeList.cpp1
-rw-r--r--lib/Sema/SemaDeclAttr.cpp27
2 files changed, 27 insertions, 1 deletions
diff --git a/lib/Sema/AttributeList.cpp b/lib/Sema/AttributeList.cpp
index 789c17b7f0..6aa9690476 100644
--- a/lib/Sema/AttributeList.cpp
+++ b/lib/Sema/AttributeList.cpp
@@ -133,5 +133,6 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) {
.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 e9f885e62f..b0e022fd33 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -2516,7 +2516,29 @@ static void HandleNSReturnsRetainedAttr(Decl *d, const AttributeList &Attr,
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 @@ static void ProcessDeclAttribute(Scope *scope, Decl *D,
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();