[PATCH] D26846: __uuidof() and declspec(uuid("...")) should be allowed on enumeration types

Kevin Puetz via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 18 04:42:52 PST 2016


puetzk created this revision.
puetzk added a subscriber: cfe-commits.
puetzk set the repository for this revision to rL LLVM.

Although not specifically mentioned in the documentation, MSVC accepts __uuidof(…) and declspec(uuid("…")) attributes on enumeration types in addition to structs/classes. This is meaningful, as such types *do* have associated UUIDs in ActiveX typelibs, and such attributes are included by default in the wrappers generated by their #import construct, so they are not particularly unusual.

clang currently rejects the declspec with a –Wignored-attributes warning, and errors on __uuidof() with “cannot call operator __uuidof on a type with no GUID” (because it rejected the uuid attribute, and therefore finds no value). This is causing problems for us while trying to use clang-tidy on a codebase that makes heavy use of ActiveX.

I believe I have found the relevant places to add this functionality, this patch adds this case to clang’s implementation of these MS extensions. 
patch is against r285994 (or actually the git mirror 80464680ce).

Both include an update to test/Parser/MicrosoftExtensions.cpp to exercise the new functionality.

This is my first time contributing to LLVM, so if I’ve missed anything else needed to prepare this for review just let me know!

__uuidof: https://msdn.microsoft.com/en-us/library/zaah6a61.aspx
declspec(uuid("…")): https://msdn.microsoft.com/en-us/library/3b6wkewa.aspx
#import: https://msdn.microsoft.com/en-us/library/8etzzkb6.aspx


Repository:
  rL LLVM

https://reviews.llvm.org/D26846

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/AttributeList.h
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaExprCXX.cpp
  test/Parser/MicrosoftExtensions.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26846.78499.patch
Type: text/x-patch
Size: 3966 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161118/cc1b93fd/attachment.bin>


More information about the cfe-commits mailing list