diff --git a/.clang-tidy b/.clang-tidy --- a/.clang-tidy +++ b/.clang-tidy @@ -7,11 +7,11 @@ - key: readability-identifier-naming.FunctionCase value: camelBack - key: readability-identifier-naming.MemberCase - value: CamelCase + value: camelBack - key: readability-identifier-naming.ParameterCase - value: CamelCase + value: camelBack - key: readability-identifier-naming.UnionCase value: CamelCase - key: readability-identifier-naming.VariableCase - value: CamelCase + value: camelBack diff --git a/clang/.clang-tidy b/clang/.clang-tidy --- a/clang/.clang-tidy +++ b/clang/.clang-tidy @@ -12,11 +12,11 @@ - key: readability-identifier-naming.FunctionCase value: camelBack - key: readability-identifier-naming.MemberCase - value: CamelCase + value: camelBack - key: readability-identifier-naming.ParameterCase - value: CamelCase + value: camelBack - key: readability-identifier-naming.UnionCase value: CamelCase - key: readability-identifier-naming.VariableCase - value: CamelCase + value: camelBack diff --git a/llvm/.clang-tidy b/llvm/.clang-tidy --- a/llvm/.clang-tidy +++ b/llvm/.clang-tidy @@ -7,11 +7,11 @@ - key: readability-identifier-naming.FunctionCase value: camelBack - key: readability-identifier-naming.MemberCase - value: CamelCase + value: camelBack - key: readability-identifier-naming.ParameterCase - value: CamelCase + value: camelBack - key: readability-identifier-naming.UnionCase value: CamelCase - key: readability-identifier-naming.VariableCase - value: CamelCase + value: camelBack diff --git a/llvm/docs/CodingStandards.rst b/llvm/docs/CodingStandards.rst --- a/llvm/docs/CodingStandards.rst +++ b/llvm/docs/CodingStandards.rst @@ -1191,8 +1191,9 @@ nouns and start with an upper-case letter (e.g. ``TextFileReader``). * **Variable names** should be nouns (as they represent state). The name should - be camel case, and start with an upper case letter (e.g. ``Leader`` or - ``Boats``). + be camel case, and start with a lower case letter (e.g. ``leader`` or + ``boats``). It is also acceptable to use ``UpperCamelCase`` for consistency + with existing code. * **Function names** should be verb phrases (as they represent actions), and command-like function should be imperative. The name should be camel case, @@ -1232,16 +1233,22 @@ class VehicleMaker { ... - Factory F; // Bad -- abbreviation and non-descriptive. - Factory Factory; // Better. - Factory TireFactory; // Even better -- if VehicleMaker has more than one - // kind of factories. + Factory f; // Bad -- abbreviation and non-descriptive. + Factory factory; // Better. + Factory tireFactory; // Even better -- if VehicleMaker has more than + // one kind of factory. }; - Vehicle makeVehicle(VehicleType Type) { - VehicleMaker M; // Might be OK if having a short life-span. - Tire Tmp1 = M.makeTire(); // Bad -- 'Tmp1' provides no information. - Light Headlight = M.makeLight("head"); // Good -- descriptive. + Vehicle makeVehicle(VehicleType type) { + // Reusing the type name in lowerCamelCase form is often a good way to get + // a suitable variable name. + VehicleMaker vehicleMaker; + + // Bad -- 'tmp1' provides no information. + Tire tmp1 = vehicleMaker.makeTire(); + + // Good -- descriptive. + Light headlight = vehicleMaker.makeLight("head"); ... }