<div dir="ltr"><div dir="ltr">On Thu, Aug 19, 2021 at 11:23 AM Fāng-ruì Sòng <<a href="mailto:maskray@google.com">maskray@google.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Thu, Aug 19, 2021 at 10:55 AM David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<br>
><br>
> On Wed, Aug 18, 2021 at 4:50 PM Fāng-ruì Sòng via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
>><br>
>> Hi all,<br>
>><br>
>> I created a .clang-tidy patch <a href="https://reviews.llvm.org/D108265" rel="noreferrer" target="_blank">https://reviews.llvm.org/D108265</a> to push<br>
>> the variable naming related options from<br>
>> top-level .clang-tidy down to the projects actually using the style<br>
>> (llvm/, clang-tools-extra/).<br>
>><br>
>> The rationale is: uppercase VariableName doesn't really reflect the<br>
>> reality for many projects and (in my view) is a bad<br>
>> suggestion for new projects. My summary about the reality:<br>
>><br>
>> * Use VariableName and have readability-identifier-naming check: llvm,<br>
>> clang-tools-extra, parallel-libs, polly<br>
>> * Use VariableName but disable readability-identifier-naming: clang<br>
>> * Use lowercase variable names and disable<br>
>> readability-identifier-naming: (mostly lowercase) compiler-rt, flang,<br>
>> lldb<br>
>> * Use lowercase variable names and enable<br>
>> readability-identifier-naming: libc, libclc, libcxx, libcxxabi,<br>
>> libunwind, lld, mlir, openmp, pstl<br>
>><br>
>> (I noticed the issue because some Phabricator bot wanted me to use<br>
>> VariableName for a libunwind patch of mine.<br>
>> The request looked unreasonable to me. I could add<br>
>> libunwind/.clang-tidy, but I figured out the top-level .clang-tidy<br>
>> problem.)<br>
>><br>
>> From my vague memory about previous discussion on variable names, most<br>
>> people agree that VariableName was a mistake and new projects do not<br>
>> necessarily need to follow.<br>
><br>
><br>
> Might be worth going back over those discussions and summarizing/linking to supporting archives, etc, so we don't rehash the whole conversation again here? (& cc'ing interested parties so they don't have to stumble across this thread or miss it by accident)<br>
<br>
<a href="https://llvm.org/docs/Proposals/VariableNames.html#introduction" rel="noreferrer" target="_blank">https://llvm.org/docs/Proposals/VariableNames.html#introduction</a> has a<br>
summary of the 2019 discussion.<br>
<br>
"There is some agreement that the current rule is broken<br>
[LattnerAgree] [ArsenaultAgree] [RobinsonAgree] and that acronyms are<br>
an obstacle to reading new code [MalyutinDistinguish] [CarruthAcronym]<br>
[PicusAcronym]. There are some opposing views [ParzyszekAcronym2]<br>
[RicciAcronyms]."<br>
<br>
Perhaps "some" can be converted to "majority" or "full".<br>
Everyone thinks VariableName was a mistake.<br></blockquote><div><br></div><div>"everyone" might be too strong a statement - there's no real way to determine that, effectively.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
(The "opposing views" were about whether it was worthwhile to switch<br>
to a variant of lowerCase/lower_case for existing code (mostly llvm/,<br>
clang/, clang-tools-extra/).)<br></blockquote><div><br>Personally, I don't find one naming convention over another (of the ones being considered) to be sufficiently different in usability to justify making any changes. But partly to justify making lots of changes to LLVM core, or, in the absence of such changes, to create more divergence between that code and other subprojects (because most folks will work on LLVM core + some subprojects, so consistency with LLVM core is pretty important).<br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
>> However, one feedback is that<br>
>> <a href="https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly" rel="noreferrer" target="_blank">https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly</a><br>
>> says<br>
>><br>
>> > Variable names should be nouns (as they represent state). The name should be camel case, and start with an uppercase letter (e.g. Leader or Boats).<br>
>><br>
>> so the top-level .clang-tidy should keep the `VariableName` suggestion<br>
>> and should apply to new top-level projects.<br>
>><br>
>> Request<br>
>> =======<br>
>><br>
>> I would like to get feedback on the following two points:<br>
>><br>
>> 1. Should we proceed with the .clang-tidy change<br>
>> <a href="https://reviews.llvm.org/D108265" rel="noreferrer" target="_blank">https://reviews.llvm.org/D108265</a> ?<br>
>> 2. Should the VariableName wording on CodingStandards.html be<br>
>> clarified/relaxed? llvm, clang, and clang-tools-extra can keep using<br>
>> it but lowercase names should also be allowed.<br>
><br>
><br>
> Further thought: I don't think (1) should proceed as-is no matter the decision on (2). We should have an LLVM umbrella naming convention (I don't think the number of projects that use one or the other should be a vote in favor or against - LLVM Core is still the core of the umbrella project and has more weight here than other subprojects (not the only thing that matters, but part of it), removing any naming convention I think would be unhelpful.<br>
> & I don't think (2) should be "use either of these naming conventions" it should be "this is the naming convention" perhaps with a note that LLVM Core (& some other places, such as clang-tools-extra) uses a different one for historical reasons, for instance.<br>
<br>
<br>
There were debates about whether camelCase/snake_case should be used<br>
for variable names,<br>
Personally I am fine with either one but slightly prefer snake_case.<br>
New projects using either form will be fine to me.<br>
<br>
For (1), I have some doubt whether there will be an LLVM umbrella<br>
naming convention for variable names,<br>
but I **don't** consider the lack of convergence (to either camelCase<br>
or snake_case) an argument for keeping VariableName in the in the<br>
top-level .clang-tidy .<br>
Actually I strongly oppose to keeping VariableName in the top-level<br>
.clang-tidy, or new projects adopting VariableName.<br></blockquote><div><br></div><div>It's pretty important to me that we don't make it easier to create more divergence in naming conventions - creating another project that diverges from LLVM's naming conventions/creates more naming inconsistency seems like a loss to me. So until there's some buy-in for a desired future direction, I think new projects should adhere to the existing convention.<br><br>I don't think that future direction must include a way to cleanup LLVM - as Chris Lattner said, maybe it is something like "<span style="color:rgb(0,0,0);white-space:pre-wrap">Even if the community does not have the appetite to do a huge scale renaming of all the things in LLVM, it would be interesting to carve out an exception for new code being written, refactored, or potentially for use in new subprojects." - though I think that's a choice we should all make together (doesn't require it to be unanimous) and carefully. That does produce the inconsistent-with-LLVM-core issue I'm concerned about, but maybe with a path forward to consistency.
Might be worth talking about whether people would be comfortable with more active cleanup - not necessarily one huge renaming, but be willing to accept patches that rename things without necessarily being pieces of code being actively refactored for other reasons. That'd help alleviate the "now we're going to have N different conventions based on when a given subproject was introduced", which increases friction when moving between subprojects (as zturner pointed out in some of the discussion/code review of style changes proposed previously).
- Dave</span></div></div></div>