[PATCH] D85398: [clang-tidy] Fix bugprone-bad-signal-to-kill-thread crash when `SIGTERM` is not a literal.
Aleksandr Platonov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 6 01:00:17 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG216ad2da74f0: [clang-tidy] Fix bugprone-bad-signal-to-kill-thread crash when `SIGTERM` is not… (authored by ArcsinX).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D85398/new/
https://reviews.llvm.org/D85398
Files:
clang-tools-extra/clang-tidy/bugprone/BadSignalToKillThreadCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/bugprone-bad-signal-to-kill-thread-sigterm-not-a-literal.cpp
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-bad-signal-to-kill-thread-sigterm-not-a-literal.cpp
===================================================================
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-bad-signal-to-kill-thread-sigterm-not-a-literal.cpp
@@ -0,0 +1,10 @@
+// RUN: clang-tidy %s --checks=-*,bugprone-bad-signal-to-kill-thread -- | count 0
+
+#define SIGTERM ((unsigned)15) // no-crash
+using pthread_t = int;
+int pthread_kill(pthread_t thread, int sig);
+
+int func() {
+ pthread_t thread;
+ return pthread_kill(thread, 0);
+}
Index: clang-tools-extra/clang-tidy/bugprone/BadSignalToKillThreadCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/bugprone/BadSignalToKillThreadCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/BadSignalToKillThreadCheck.cpp
@@ -39,6 +39,8 @@
return llvm::None;
const MacroInfo *MI = PP->getMacroInfo(It->first);
const Token &T = MI->tokens().back();
+ if (!T.isLiteral())
+ return llvm::None;
StringRef ValueStr = StringRef(T.getLiteralData(), T.getLength());
llvm::APInt IntValue;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85398.283517.patch
Type: text/x-patch
Size: 1177 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200806/694b7049/attachment.bin>
More information about the cfe-commits
mailing list