The new checker checks if inline functions defined in header files are
tagged with the LIBC_INLINE macro. See https://libc.llvm.org/code_style.html
for more information about this macro.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Please add entry in Release Notes.
clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp | ||
---|---|---|
30 | Please don't use auto unless type is explicitly stated in same statement or iterator. |
clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp | ||
---|---|---|
21 | or maybe even better: |
clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp | ||
---|---|---|
21 | 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. | |
30 | We have a well-established pattern for detecting code in headers, grep for HeaderFileExtensions in existing checks. |
clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp | ||
---|---|---|
21 | Yes you right, but isInline still can be checked here. |
clang-tools-extra/test/clang-tidy/checkers/llvmlibc/inline-function-decl.cpp | ||
---|---|---|
18–19 ↗ | (On Diff #492324) | These should specify which line they apply to, as done in all other checks. In particular, to get the unit test to work, you will not be able to use a .cpp that includes a header. The test file must be a .hpp file (for which you need HeaderFileExtensions as I said above). |
clang-tools-extra/docs/ReleaseNotes.rst | ||
---|---|---|
104 | One sentence is enough. |
clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp | ||
---|---|---|
21 | Unfortunately, even isInline is not good enough because isInline only matches functions marked with inline: https://github.com/llvm/llvm-project/blob/main/clang/include/clang/ASTMatchers/ASTMatchers.h#L7769. It misses implicitly inline functions like constexpr functions and class methods. | |
30 | Thanks! I have now switched over to use the HeaderFileExtensions pattern. |
clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp | ||
---|---|---|
28 | Check if FuncDecl is not a nullptr before dereferencing. You can do an early return like: if (!FuncDecl) return; | |
clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.h | ||
28–37 | Please implement constructor in the .cpp file. | |
40–42 | This is OK to keep in the header as it's only one line. | |
44–52 | Ditto | |
clang-tools-extra/docs/ReleaseNotes.rst | ||
100 | I believe you'll need a rebase since a new check was recently added. | |
104 | You need to also add the check to clang-tools-extra/docs/clang-tidy/checks/list.rst | |
clang-tools-extra/test/clang-tidy/checkers/llvmlibc/inline-function-decl.hpp | ||
3 | I believe this can be removed. | |
21 | Missing check name: ... LIBC_INLINE macro [llvmlibc-inline-function-decl] | |
46 | Missing line and column info |
clang-tools-extra/docs/clang-tidy/checks/llvmlibc/inline-function-decl-check.rst | ||
---|---|---|
8 ↗ | (On Diff #492661) | Document the HeaderFileExtensions option, see existing checks. |
clang-tools-extra/clang-tidy/llvmlibc/LLVMLibcTidyModule.cpp | ||
---|---|---|
28 | Remove | |
clang-tools-extra/docs/ReleaseNotes.rst | ||
100 | Remove | |
100 | Remove | |
clang-tools-extra/docs/clang-tidy/checks/llvmlibc/inline-function-decl-check.rst | ||
1 ↗ | (On Diff #492661) | Remove |
3 ↗ | (On Diff #492661) | Remove |
4 ↗ | (On Diff #492661) | Nit: remove extra = |
LGTM, thanks for the contribution! Please wait a few days for other reviewers to have a look.
Please implement constructor in the .cpp file.