This is an archive of the discontinued LLVM Phabricator instance.

[mlir] ODS: emit interface traits outside of the interface class
ClosedPublic

Authored by ftynse on Jun 16 2021, 7:38 AM.

Details

Summary

ODS currently emits the interface trait class as a nested class inside the
interface class. As an unintended consequence, the default implementations of
interface methods have implicit access to static fields of the interface class,
e.g. those declared in extraClassDeclaration, including private methods (!),
or in the parent class. This may break the use of default implementations for
external models, which are not defined in the interface class, and generally
complexifies the abstraction.

Emit intraface traits outside of the interface class itself to avoid accidental
implicit visibility. Public static fields can still be accessed via explicit
qualification with a class name, e.g., MyOpInterface::staticMethod() instead
of staticMethod.

Update the documentation to clarify the role of extraClassDeclaration in
interfaces.

Diff Detail

Event Timeline

ftynse created this revision.Jun 16 2021, 7:38 AM
ftynse requested review of this revision.Jun 16 2021, 7:38 AM
rriddle accepted this revision.Jun 16 2021, 5:32 PM
This revision is now accepted and ready to land.Jun 16 2021, 5:32 PM