[llvm] r175847 - Code cleanup: pass Offset by pointer to parseInstruction to more explicitly

Eli Bendersky eliben at google.com
Fri Feb 22 10:12:05 PST 2013


>> This is mainly bringing the code in line with the other DataExtractor
>> use cases. DataExtractor's getXXX methods take a pointer to offset for
>> reading it and updating it. My initial code used a reference, and I
>> wanted it to be more consistent now. As for the coding convention, I
>> know we don't have an explicit guideline for this, and yet I
>> personally prefer not to use references in such cases, because looking
>> at:
>>
>> doFoo(param)
>>
>> It's really hard to immediately see that param can be modified by
>> doFoo. But looking at:
>>
>> doFoo(&param)
>>
>> It's easier.
>>
>> But this is a minor argument. The main one is the consistency.
>
>
> Oh, OK - I'll totally buy an argument from consistency if the code you're
> being consistent with is nearby/obviously in contrast (ie: the two uses sit
> side by side & would confuse users - which I guess is the case here), but if
> we're both in agreement (a preference for reference in/out params) why not
> just fix DataExtractor instead (& that way it'll be consistent with the rest
> of the codebase)? It's not a huge class & the transformation would be fairly
> easy I would think...
>

To clarify, I'm in favor of keeping the existing "INOUT by pointer"
convention in DataExtractor, and by extension in nearby code.

Eli



More information about the llvm-commits mailing list