Visual C++ __interface keyword

I'm running into problems compiling code that uses the
Microsoft-specific __interface keyword. Although it's been implemented
in clang as an alias for struct, it's missing the automatic pure virtual
specifier for member functions that is implied by the keyword.

I understand that implementing MS-specific keywords likely isn't high on
anyone's list, and was hoping to be able to make the change myself if it
is something that would be accepted as a patch (provided it conforms to
the coding standards, has tests, etc.; I have read the internals/hacking
pages).

While not new to compilers generally I'm new to clang, so pointers for
this task would be appreciated. As I see it I first have to upgrade
__interface to a keyword in TokenKinds.def so it can be appropriately
detected at higher levels (and still mostly treated as a struct) -
perhaps set a flag in CXXRecordDecl, and apply the pure/virtual
specifiers when a method within the interface is parsed?

Can __interface be used in all the same ways as a standard class-key?

That is, can you write:
  __interface foo; // forward declaration
or
  __interface foo *ptr = 0; // elaborated type specifier

If so, the right way to model this in the AST is to add it as a new alternative
to both TypeSpecifierType (in clang/Basic/Specifiers.h) and TagTypeKind
(in clang/AST/Type.h). You might have to audit all the places that store the
latter to make sure they don't stuff it into a 2-bit bitfield. You'll also have to
audit all the users to make sure that they do the right thing on the new
alternative.

If not, it would be less invasive to model this as an attribute and either
  (1) make __interface a macro that expands to 'struct [[ms_interface]]' or
  (2) make the parser recognize the keyword and add the attribute.

John.

Can __interface be used in all the same ways as a standard class-key?

That is, can you write:
  __interface foo; // forward declaration
or
  __interface foo *ptr = 0; // elaborated type specifier

Yes. However, either 'struct' or 'class' can be used to define class foo
subsequently. Could it still work as an attribute? That seems like a
good way to proceed.

If so, the right way to model this in the AST is to add it as a new alternative
to both TypeSpecifierType (in clang/Basic/Specifiers.h) and TagTypeKind
(in clang/AST/Type.h). You might have to audit all the places that store the
latter to make sure they don't stuff it into a 2-bit bitfield. You'll also have to
audit all the users to make sure that they do the right thing on the new
alternative.

If not, it would be less invasive to model this as an attribute and either
  (1) make __interface a macro that expands to 'struct [[ms_interface]]' or
  (2) make the parser recognize the keyword and add the attribute.

Option 2 seems better (vs. having to always #define a macro and the
added expansion layer), and a number of MS-only keywords are already
defined. What's the right point to convert the keyword into "struct" +
attribute?

Looking at Attr.td an attribute with Subjects = [CXXRecord] seems to be
the right place to start; I'll examine how similar attributes are used
through the source.

Thank you for your help.