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 @@ -30,7 +30,8 @@ void BadSignalToKillThreadCheck::check(const MatchFinder::MatchResult &Result) { const auto IsSigterm = [](const auto &KeyValue) -> bool { - return KeyValue.first->getName() == "SIGTERM"; + return KeyValue.first->getName() == "SIGTERM" && + KeyValue.first->hasMacroDefinition(); }; const auto TryExpandAsInteger = [](Preprocessor::macro_iterator It) -> Optional { diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone-bad-signal-to-kill-thread-undef-sigterm.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone-bad-signal-to-kill-thread-undef-sigterm.cpp new file mode 100644 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-bad-signal-to-kill-thread-undef-sigterm.cpp @@ -0,0 +1,11 @@ +// RUN: clang-tidy %s --checks=-*,bugprone-bad-signal-to-kill-thread -- | count 0 + +#define SIGTERM 15 +#undef SIGTERM // no-crash +using pthread_t = int; +int pthread_kill(pthread_t thread, int sig); + +int func() { + pthread_t thread; + return pthread_kill(thread, 0); +}