This is an archive of the discontinued LLVM Phabricator instance.

Add isa<> support to MachOFile
ClosedPublic

Authored by pete on Jan 11 2016, 5:52 PM.

Details

Summary

Hi all

I'm in need of something more fine grained that the kind() method on File. It can only distinguish .o, .so, and .a, but I need to know if, for example, a File* is a MachOFile vs another subclass of SimpleFile like CEntryFile.

This patch is a preliminary implementation which only adds enough to get isa<> to work on MachOFile. If you are all happy with the direction then i'll add support for all of the subclasses of File so that we can do isa<> on anything in the tree.

Alternatively, if only SimpleFile is expected to have interesting subclasses, then i could instead add a SubKind field to SimpleFile instead of changing kind() in File. (BTW, I don't intend for kindUnknownObject to be around for long. If I can do isa<> on all the subclasses then each subclass will have its own entry).

Feedback welcome.

Thanks,
Pete

Diff Detail

Repository
rL LLVM

Event Timeline

pete updated this revision to Diff 44593.Jan 11 2016, 5:52 PM
pete retitled this revision from to Add isa<> support to MachOFile.
pete updated this object.
pete added reviewers: lhames, kledzik, ruiu, rafael.
pete added a project: lld.
pete added a subscriber: llvm-commits.
lhames accepted this revision.Jan 14 2016, 2:21 PM
lhames edited edge metadata.

I've been trying to think of a better way to do this, but I haven't come up with anything yet. It's a pity that we end up mirroring some of the RTTI in the libObject hierarchy, but this really is a distinct hierarchy.

LGTM.

This revision is now accepted and ready to land.Jan 14 2016, 2:21 PM
This revision was automatically updated to reflect the committed changes.