Page MenuHomePhabricator

AST: support protocol conformances on id/class/interfaces in MS ABI

Authored by compnerd on Jan 24 2018, 3:02 PM.



Add support for mangling ObjC protocol conformances in MS ABI as if they are COM interfaces. By diverging from the itanium mangling of objc_protocol prefixed names, this approach allows for a semi-reasonable, albeit of questionable sanity, undecoration via existing tooling. There is also the possibility of adding an extension and taking part of the namespace to add the conformance via the L and Z "modifiers", but the existing tooling would not be able to properly undecorated the symbol even though incidentally undname currently produces something legible while wine's implementation is not able to cope with the extension.

This allows for the disambiguation of overloads where the parameter differs only in the protocol conformance of the ObjC type, e.g.

@protocol P;
void f(std::vector<id>);
void f(std::vector<id<P>>);

which clang would previously fail due to the mangling being identical as the protocol conformance was ignored.

Diff Detail

rC Clang

Event Timeline

compnerd created this revision.Jan 24 2018, 3:02 PM
majnemer added inline comments.

Hmm, this is a template... I don't think this will do the right thing wrt backreferences.


Probably want a comment stating that this is cointerface.

The basic idea here seems fine to me; I'll leave David to review the details.

compnerd updated this revision to Diff 131379.Jan 24 2018, 5:50 PM
compnerd marked an inline comment as done.

scope the template back references and add a comment.

compnerd updated this revision to Diff 131477.Jan 25 2018, 10:12 AM

Add additional test cases as discussed on IRC. These ensure that the back reference handling is correct.

This revision is now accepted and ready to land.Jan 25 2018, 4:15 PM
compnerd closed this revision.Jan 26 2018, 3:10 PM

SVN r323547