This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Make getWasmType a non-member function.
ClosedPublic

Authored by ruiu on Feb 23 2018, 8:35 PM.

Details

Summary

A function that doesn't use any private member should be defined as
a non-member function, so that it is obvious that it uses only public
interfaces of a given object.

Diff Detail

Repository
rLLD LLVM Linker

Event Timeline

ruiu created this revision.Feb 23 2018, 8:35 PM

I'm not sure I agree with the premis in the change description. There are plenty of times when a method makes sense even though it operates on only the public members (if only to take advantage of the implicit this and to keep data and logic grouped together). For example most of the methods in elf::Symbol only use public fields.

However I do like the re-write of this code. Would you consider re-writing but keeping it as method (using isa..(this) instead)?

sbc100 requested changes to this revision.Feb 27 2018, 3:46 PM
This revision now requires changes to proceed.Feb 27 2018, 3:46 PM
ruiu updated this revision to Diff 136201.Feb 27 2018, 5:08 PM
  • revert everything except getWasmType
sbc100 accepted this revision.Feb 27 2018, 5:11 PM
This revision is now accepted and ready to land.Feb 27 2018, 5:11 PM
This revision was automatically updated to reflect the committed changes.