[PATCH] [lld] ELF: Support detection of relocation errors during processing

Nick Kledzik kledzik at apple.com
Fri Jan 9 13:41:08 PST 2015


On Jan 9, 2015, at 4:13 AM, Will Newton <will.newton at linaro.org> wrote:
> On 8 January 2015 at 23:04, Rui Ueyama <ruiu at google.com> wrote:
>> REPOSITORY
>>  rL LLVM
>> 
>> ================
>> Comment at: lib/Core/Error.cpp:123
>> @@ -100,1 +122,3 @@
>> +}
>> +
>> 
>> ----------------
>> Instead of adding a new error category for your purpose, I think it would be better to just use make_dynamic_error_code(). It's simpler to use.
> 
> Thanks for the suggestion. As I understand it using a dynamic error we
> get to remove the error category machinery which is a win in terms of
> code size and complexity but it would involve replacing all uses of
> say RelocationError::out_of_range with something like
> make_dynamic_error_code(Twine("out of range")) which seems a bit
> uglier and repetitious. I would expect that the majority of relocation
> processing functions should be capable of returning an error code so
> that code could be repeated possibly hundreds of times.
> 
> How do you see the pros and cons of each approach?
You could make a helper function:

  std::error_code make_out_of_range_reloc_error(Twine& msg) {
	return make_dynamic_error_code(Twine(“out of range”) + msg);
}

Making a new category with new values is interesting if you need to programmatically handle the various errors.  If you just need to pass a message string, make_dynamic_error_code() does that.

-Nick





More information about the llvm-commits mailing list