[PATCH] D88140: [clang-tidy] Check for sigaction in cert-sig30-c.
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 25 06:11:28 PDT 2020
aaron.ballman added inline comments.
================
Comment at: clang-tools-extra/clang-tidy/cert/SignalHandlerCheck.cpp:91
+ hasObjectExpression(ignoringParenImpCasts(declRefExpr(
+ anyOf(hasType(recordDecl(hasName("sigaction"))),
+ hasType(pointsTo(recordDecl(hasName("sigaction"))))))));
----------------
You should be checking for the fully-qualified name so that this doesn't trip it up:
```
namespace awesome {
struct sigaction {
const char *terrible = "haha";
};
}
```
================
Comment at: clang-tools-extra/clang-tidy/cert/SignalHandlerCheck.cpp:92
+ anyOf(hasType(recordDecl(hasName("sigaction"))),
+ hasType(pointsTo(recordDecl(hasName("sigaction"))))))));
+ auto HandlerMember = member(hasName("sa_handler"));
----------------
I'd like to see a test case that this works properly with references in C++ (in addition to pointers).
================
Comment at: clang-tools-extra/test/clang-tidy/checkers/cert-sig30-c.cpp:152
+ SA->sa_sigaction = sigaction_handler5;
+}
----------------
I'd like to see a test case that shows this works if the `sigaction` object is within another structure. e.g.,
```
struct foo {
struct sigaction act;
};
void test(void) {
struct foo f;
f.act.sa_handler = handler_sigaction5;
}
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D88140/new/
https://reviews.llvm.org/D88140
More information about the cfe-commits
mailing list