[cfe-commits] [patch] Add codegen support for __uuidof

Nico Weber thakis at chromium.org
Sun Sep 30 23:56:38 PDT 2012


Hi,

the attached patch adds codegen support for __uuidof. It's fairly
similar to how the RTTI descriptor code works. What __uuidof does:
Structs can be tagged with __declspec(uuid("some string with
numbers")), and after that __uuidof(taggedstruct) returns a IID struct
filled with the numbers from the uuid declspec attribute. See
test/Parser/MicrosoftExtensions.cpp and the included test for more
information.

I moved GetUuidAttrOfType() out of Sema since codegen now needs it
too. I couldn't find a great place for it -- it's a static function on
CXXUuidofExpr. Since that expression isn't very useful without uuid
attrs, it's a reasonable place for it I think.

I'm not very familiar with visibilities. WeakAnyLinkage is mostly a
guess, so please check that.

The name of the symbol generated for __uuidof constants seems to be an
implementation detail, so I just made up a mangling ("__uuid_"
followed by the contents of the uuid, see GetAddrOfIIDDescriptor()).

Nico
-------------- next part --------------
A non-text attachment was scrubbed...
Name: uuid.patch
Type: application/octet-stream
Size: 14815 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121001/1484c889/attachment.obj>


More information about the cfe-commits mailing list