[llvm-dev] Top-level .clang-tidy options and VariableName suggestion on CodingStandards
Fāng-ruì Sòng via llvm-dev
llvm-dev at lists.llvm.org
Thu Aug 19 11:23:00 PDT 2021
On Thu, Aug 19, 2021 at 10:55 AM David Blaikie <dblaikie at gmail.com> wrote:
> On Wed, Aug 18, 2021 at 4:50 PM Fāng-ruì Sòng via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>> Hi all,
>> I created a .clang-tidy patch https://reviews.llvm.org/D108265 to push
>> the variable naming related options from
>> top-level .clang-tidy down to the projects actually using the style
>> (llvm/, clang-tools-extra/).
>> The rationale is: uppercase VariableName doesn't really reflect the
>> reality for many projects and (in my view) is a bad
>> suggestion for new projects. My summary about the reality:
>> * Use VariableName and have readability-identifier-naming check: llvm,
>> clang-tools-extra, parallel-libs, polly
>> * Use VariableName but disable readability-identifier-naming: clang
>> * Use lowercase variable names and disable
>> readability-identifier-naming: (mostly lowercase) compiler-rt, flang,
>> * Use lowercase variable names and enable
>> readability-identifier-naming: libc, libclc, libcxx, libcxxabi,
>> libunwind, lld, mlir, openmp, pstl
>> (I noticed the issue because some Phabricator bot wanted me to use
>> VariableName for a libunwind patch of mine.
>> The request looked unreasonable to me. I could add
>> libunwind/.clang-tidy, but I figured out the top-level .clang-tidy
>> From my vague memory about previous discussion on variable names, most
>> people agree that VariableName was a mistake and new projects do not
>> necessarily need to follow.
> 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)
https://llvm.org/docs/Proposals/VariableNames.html#introduction has a
summary of the 2019 discussion.
"There is some agreement that the current rule is broken
[LattnerAgree] [ArsenaultAgree] [RobinsonAgree] and that acronyms are
an obstacle to reading new code [MalyutinDistinguish] [CarruthAcronym]
[PicusAcronym]. There are some opposing views [ParzyszekAcronym2]
Perhaps "some" can be converted to "majority" or "full".
Everyone thinks VariableName was a mistake.
(The "opposing views" were about whether it was worthwhile to switch
to a variant of lowerCase/lower_case for existing code (mostly llvm/,
>> However, one feedback is that
>> > 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).
>> so the top-level .clang-tidy should keep the `VariableName` suggestion
>> and should apply to new top-level projects.
>> I would like to get feedback on the following two points:
>> 1. Should we proceed with the .clang-tidy change
>> https://reviews.llvm.org/D108265 ?
>> 2. Should the VariableName wording on CodingStandards.html be
>> clarified/relaxed? llvm, clang, and clang-tools-extra can keep using
>> it but lowercase names should also be allowed.
> 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.
> & 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.
There were debates about whether camelCase/snake_case should be used
for variable names,
Personally I am fine with either one but slightly prefer snake_case.
New projects using either form will be fine to me.
For (1), I have some doubt whether there will be an LLVM umbrella
naming convention for variable names,
but I **don't** consider the lack of convergence (to either camelCase
or snake_case) an argument for keeping VariableName in the in the
top-level .clang-tidy .
Actually I strongly oppose to keeping VariableName in the top-level
.clang-tidy, or new projects adopting VariableName.
More information about the llvm-dev