[clangd] Fix crash in bugprone-bad-signal-to-kill-thread clang-tidy check.
authorAleksandr Platonov <platonov.aleksandr@huawei.com>
Thu, 6 Aug 2020 18:44:08 +0000 (21:44 +0300)
committerAleksandr Platonov <platonov.aleksandr@huawei.com>
Thu, 6 Aug 2020 18:45:21 +0000 (21:45 +0300)
commit9f24148b212698aca220ac923d215c2073e443ce
tree39d38423850991e2abbec44077a3506d10c9bec3
parent4ccc38813eb76c7984f2700df527c643abeb9a58
[clangd] Fix crash in bugprone-bad-signal-to-kill-thread clang-tidy check.

Inside clangd, clang-tidy checks don't see preprocessor events in the preamble.
This leads to `Token::PtrData == nullptr` for tokens that the macro is defined to.
E.g. `#define SIGTERM 15`:
- Token::Kind == tok::numeric_constant (Token::isLiteral() == true)
- Token::UintData == 2
- Token::PtrData == nullptr

As the result of this, bugprone-bad-signal-to-kill-thread check crashes at null-dereference inside clangd.

Reviewed By: hokein

Differential Revision: https://reviews.llvm.org/D85417
clang-tools-extra/clang-tidy/bugprone/BadSignalToKillThreadCheck.cpp
clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp