[cfe-dev] [PATCH] clang: Style changes to ParseAST.[cpp,h].

John McCall rjmccall at apple.com
Sun Apr 3 01:29:31 PDT 2011


On Apr 3, 2011, at 12:14 AM, John McCall wrote:
> On Apr 2, 2011, at 10:46 PM, Thiago Farina wrote:
>> - makes all function parameter names start with a lower case letter
>> for consistency and distinction from member variables.
> 
> As I understand it, our current policy is to not accept pure style rewrites —
> we'd just use a code formatter to apply style changes universally if we
> were going to do that.  Feel free to bring code in line with the new code
> style guidelines when making other changes in a file, though
> preferably in a separate patch.

Thiago very reasonably pointed out to me that this isn't a very clear
guideline, so let try to elaborate;  maybe people disagree with my
reasoning here.

Whenever dealing with old code that doesn't conform perfectly to
our ideals, there's a balance to be struck between (1) improving it
and (2) making it easy to figure out how the code got into its
current state.  This is an inherent tension — every non-semantic
change is something that someone investigating the code history
has to compensate for.  Now, I — and the LLVM/Clang community
in general, I think — believe quite strongly that that balance needs
to be heavily biased towards improving the code, and that almost
any change is a good enough improvement to meet this threshold.
For example, Zhanyong's patch from February renamed some
functions to avoid unnecessary abbreviations, and Ted felt (and I
agree) that that was a useful improvement, and that it was worth
bringing things in line with the code style guidelines at the same
time.  Whereas here I feel that just changing the capitalization of
local variables has pretty marginal value, and the abbreviations
you're avoiding are pretty pervasive throughout Parser and Sema,
so it doesn't meet my threshold.

Also, it doesn't look like this is in the style guidelines, but we
camelCase identifiers instead of underscore_separating them
except in certain circumstances, like enumerator prefixes.

John.



More information about the cfe-dev mailing list