[PATCH] ELF: Move relocation predicates out of the context class.

Simon Atanasyan simon at atanasyan.com
Wed Feb 18 00:10:26 PST 2015

On Wed, Feb 18, 2015 at 1:58 AM, Rui Ueyama <ruiu at google.com> wrote:
> I think I read about this in Effective C++ and that's a good practice -- if
> your functionality uses only public interface of other classes, making it a
> non-member function is preferred. By doing that it cuts dependencies and it
> also make it obvious that the function doesn't depend on any hidden
> information. I believe this is exactly what I'm trying to do in this patch.

It cuts dependencies in sense of C++ but add dependencies on module
level. Now to drop old target or add new one you need to change the
code in many places. Moreover now "elf core" knows about kind of
relocations of all targets.

By the way, the initial idea was to reduce code duplication. I missed
the moment when the main target becomes reducing of dependencies.

As to me if we really want to apply this practice from Effective C++
here, let's introduce isXXXDynamicRelocation() functions where XXX is
a target name and call these functions from the main
isDynamicRelocation() routine. This does not make the code better but
allows us to follow the practice ;)

Simon Atanasyan

More information about the llvm-commits mailing list