[PATCH] D37308: Interface class with uuid base record

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 31 16:02:23 PDT 2017

erichkeane added a comment.

In https://reviews.llvm.org/D37308#858309, @zahiraam wrote:

> Aaron,
> Yes I want to this to succeed:
> struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) IUnknown {};
>  __interface ISfFileIOPropertyPage : public IUnknown {};
> But I also want this to succeed:
> struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) IUnknown {};
>  struct IPropertyPage : public IUnknown {};
>  __interface ISfFileIOPropertyPage : public IPropertyPage {};
> And I can't figure out how these 2 can be differentiated. I think the conditions that I have currently are differently too. This later case doesn't succeed with the current code. 
>  And I want this to fail:
> class __declspec(uuid("00000000-0000-0000-C000-000000000046")) IUnknown1 {};
>  __interface __declspec(dllimport) ISfFileIOPropertyPage1 : public IUnknown1 {};
> This currently does with the current code.
> I guess I need to work on it a bit more.

It definitely looks like you'll have to walk the inheritance tree to get the 2nd example to work.  Based on that, the rule seems to be, an __interface can inherit from:
1 - Another __interface
2 - The COMPLETE IUnknown type, such that it is a struct, with a uuid of 000...C000...46, named "IUnknown", with an empty definition. (note that this is independent of namespace)
3- Any other type that:
-a: is a class or struct
-b: has no members
-c: inherits from at least 1 type that:
--I: Is an IUnknown type (in any namespace)  --or--
--II: A type that satisfies this point 3.
-d: Inherits from no types other than those in -c.

Note that multiple inheritance is permitted:

  namespace S{
  struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) IUnknown {};
  namespace S2{
  struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) IUnknown {};
  class __declspec(deprecated("asdf")) IPropertyPage2 : S::IUnknown, S2::IUnknown { }; // Inherits from 2 different IUnknowns
  class __declspec(deprecated("asdf")) IPropertyPage3 : S::IUnknown, S2::IUnknown { }; 
  class IP3 : IPropertyPage2, IPropertyPage3 {}; // Inherits from 2 different classes that meet #3 above.


More information about the cfe-commits mailing list