[PATCH] D73098: [clang-tidy] readability-identifier-naming disregards parameters restrictions on main like functions
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 22 06:52:56 PST 2020
aaron.ballman added a comment.
In D73098#1832489 <https://reviews.llvm.org/D73098#1832489>, @njames93 wrote:
> In D73098#1832131 <https://reviews.llvm.org/D73098#1832131>, @Mordante wrote:
>
> > Would it make sense to also allow wmain with wchar_t? https://docs.microsoft.com/en-us/cpp/cpp/main-function-command-line-args?view=vs-2019
>
>
> Does wmain get used in a lot of projects. If it's very niche then I don't feel it warrants a place in here. If it does I'll add it in.
It's not uncommon on Windows, at the very least. I think it's worth supporting.
================
Comment at: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:474
if (const auto *Decl = dyn_cast<ParmVarDecl>(D)) {
+ if (isParamInMainLikeFunction(*Decl))
+ return SK_Invalid;
----------------
njames93 wrote:
> aaron.ballman wrote:
> > I think a better approach may be to look at the `DeclContext` for the `ParmVarDecl` object to see if it is a `FunctionDecl`, and if it is, call `FunctionDecl::isMain()` to check.
> I specifically didn't want to do that as is I want to get functions that act like main, usually the case when main itself dispatches to other functions with the same signature.
I'm not certain that's a case we should support -- users who write their own main-like interfaces should probably follow their usual naming rules (even if we don't do it ourselves). For instance, this will catch functions that are definitely *not* `main`-like except in the signature. e.g., `int accumulate_string_lengths(int count, char *strings[]);`
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D73098/new/
https://reviews.llvm.org/D73098
More information about the cfe-commits
mailing list