[clang-tools-extra] [clang-tidy] Improve alternate snake case warnings (PR #71385)

J.C. Moyer via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 6 08:00:31 PST 2023


================
@@ -871,8 +871,8 @@ bool IdentifierNamingCheck::matchesStyle(
       llvm::Regex("^[a-z][a-zA-Z0-9]*$"),
       llvm::Regex("^[A-Z][A-Z0-9_]*$"),
       llvm::Regex("^[A-Z][a-zA-Z0-9]*$"),
-      llvm::Regex("^[A-Z]([a-z0-9]*(_[A-Z])?)*"),
-      llvm::Regex("^[a-z]([a-z0-9]*(_[A-Z])?)*"),
+      llvm::Regex("^[A-Z]+([a-z0-9]*_[A-Z0-9]+)*[a-z0-9]*$"),
+      llvm::Regex("^[a-z]+([a-z0-9]*_[A-Z0-9]+)*[a-z0-9]*$"),
       llvm::Regex("^[A-Z]([a-z0-9_]*[a-z])*$"),
----------------
jcmoyer wrote:

I think it's fine, `Leading_upper_snake_case` only has the first letter capitalized and no special requirements beyond that. Though maybe the regex could be slightly simplified to something like `^[A-Z][a-z0-9_]*[a-z]$`.

https://github.com/llvm/llvm-project/pull/71385


More information about the cfe-commits mailing list