Issue 170008
Summary Document fallbacks for clang-tidy readability-identifier-naming options
Labels clang-tidy
Assignees
Reporter dkaszews
    [`readability-identifier-naming`](https://clang.llvm.org/extra/clang-tidy/checks/readability/identifier-naming.html) contains a total of 56 sets of options for each of the types of symbols. Documentation seems to suggest every single one needs to be set in order for that symbol to be checked at all. But reading the code we see many of those more specific options actually have fallbacks:

```cpp
  if (isa<TemplateTypeParmDecl>(D)) {
    if (NamingStyles[SK_TypeTemplateParameter])
      return SK_TypeTemplateParameter;

    if (NamingStyles[SK_TemplateParameter])
 return SK_TemplateParameter;

    return SK_Invalid;
  }

  if (isa<NonTypeTemplateParmDecl>(D)) {
    if (NamingStyles[SK_ValueTemplateParameter])
      return SK_ValueTemplateParameter;

    if (NamingStyles[SK_TemplateParameter])
 return SK_TemplateParameter;

    return SK_Invalid;
  }

  if (isa<TemplateTemplateParmDecl>(D)) {
    if (NamingStyles[SK_TemplateTemplateParameter])
      return SK_TemplateTemplateParameter;

    if (NamingStyles[SK_TemplateParameter])
      return SK_TemplateParameter;

 return SK_Invalid;
  }
```

This shows that all of `TypeTemplate*`, `ValueTemplate*` and `TemplateTemplate*` options actually can be skipped and combined into the common `Template*`. This makes intuitive sens, but without it being documented, it is hard to make sure, especially for cases with multiple fallbacks of unknown precedence. For example, a `public static constexpr` method will use the order `ConstexprMethod`, `ConstexprFunction`, `ClassMethod`, `PublicMethod`, `Method`, `Function`, even though the user can reasonably expect that the method being `public` is more important than it being `constexpr` or `static`.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to