[PATCH] D93182: [clang-tidy] Add linux kernel log functions checker
Bill Wendling via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 16 13:36:15 PDT 2022
void added inline comments.
================
Comment at: clang-tools-extra/clang-tidy/linuxkernel/LogFunctionsCheck.cpp:51
+void LogFunctionsCheck::check(const MatchFinder::MatchResult &Result) {
+ if (FixerKind == LFFK_H) {
+ const auto *Call = Result.Nodes.getNodeAs<CallExpr>("call");
----------------
For future reference, Clang / LLVM normally likes to limit the amount of indentation that's due to checks like these. So early exit like this:
```
void LogFunctionsCheck::check(const MatchFinder::MatchResult &Result) {
if (FixerKind != LFFK_H)
return;
... // Fixer code here.
```
But I agree with @njames93 that you probably don't need the enum right now.
================
Comment at: clang-tools-extra/clang-tidy/linuxkernel/LogFunctionsCheck.cpp:53
+ const auto *Call = Result.Nodes.getNodeAs<CallExpr>("call");
+ const auto *Function = Result.Nodes.getNodeAs<FunctionDecl>("func");
+ const auto *Literal = Result.Nodes.getNodeAs<StringLiteral>("lit");
----------------
It might be worthwhile to name `Function` something like `Printk` so that the code can be more self-documenting. (Also change the bound variable from `func` to `printk`.)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D93182/new/
https://reviews.llvm.org/D93182
More information about the cfe-commits
mailing list