[PATCH] D142592: [clang-tidy][libc] Add an inline function checker for the libc project.
Carlos Galvez via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 26 06:36:07 PST 2023
carlosgalvezp added inline comments.
================
Comment at: clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp:20
+void InlineFunctionDeclCheck::registerMatchers(MatchFinder *Finder) {
+ Finder->addMatcher(decl(functionDecl()).bind("func_decl"), this);
+}
----------------
ClockMan wrote:
> or maybe even better:
> Finder->addMatcher(functionDecl(unless(isExpansionInMainFile()), isInline()).bind("func_decl"), this);
> Instead of line 26 and 32.
I'm not sure that works - if we pass a header directly to clang-tidy, it will consider it as the "main file", right? That's why the established pattern is based on `HeaderFileExtensions`, please check out other checks.
================
Comment at: clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp:29
+
+ auto SrcBegin = FuncDecl->getSourceRange().getBegin();
+ // Consider functions only in header files.
----------------
Eugene.Zelenko wrote:
> Please don't use `auto` unless type is explicitly stated in same statement or iterator.
We have a well-established pattern for detecting code in headers, grep for `HeaderFileExtensions` in existing checks.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D142592/new/
https://reviews.llvm.org/D142592
More information about the cfe-commits
mailing list