diff --git a/clang-tools-extra/clang-tidy/bugprone/BadSignalToKillThreadCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/BadSignalToKillThreadCheck.cpp --- a/clang-tools-extra/clang-tidy/bugprone/BadSignalToKillThreadCheck.cpp +++ b/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; diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone-bad-signal-to-kill-thread-sigterm-not-a-literal.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone-bad-signal-to-kill-thread-sigterm-not-a-literal.cpp new file mode 100644 --- /dev/null +++ b/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); +}