Aleksandr Platonov
9f24148b21
[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
2020-08-06 21:45:21 +03:00
Aleksandr Platonov
216ad2da74
[clang-tidy] Fix bugprone-bad-signal-to-kill-thread crash when `SIGTERM` is not a literal.
...
If `SIGTERM` is not a literal (e.g. `#define SIGTERM ((unsigned)15)`) bugprone-bad-signal-to-kill-thread check crashes.
Stack dump:
```
#0 0x000000000217d15a llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/llvm-project/build/bin/clang-tidy+0x217d15a)
#1 0x000000000217b17c llvm::sys::RunSignalHandlers() (/llvm-project/build/bin/clang-tidy+0x217b17c)
#2 0x000000000217b2e3 SignalHandler(int) (/llvm-project/build/bin/clang-tidy+0x217b2e3)
#3 0x00007f6a7efb1390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#4 0x000000000212ac9b llvm::StringRef::getAsInteger(unsigned int, llvm::APInt&) const (/llvm-project/build/bin/clang-tidy+0x212ac9b)
#5 0x0000000000593501 clang::tidy::bugprone::BadSignalToKillThreadCheck::check(clang::ast_matchers::MatchFinder::MatchResult const&) (/llvm-project/build/bin/clang-tidy+0x593501)
```
Reviewed By: hokein
Differential Revision: https://reviews.llvm.org/D85398
2020-08-06 10:32:03 +03:00
Aleksandr Platonov
8671166833
[clang-tidy] Fix bugprone-bad-signal-to-kill-thread crash when `SIGTERM` was undefined after definition.
...
`PP->getMacroInfo()` returns nullptr for undefined macro, which leads to null-dereference at `MI->tockens().back()`.
Stack dump:
```
#0 0x000000000217d15a llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/llvm-project/build/bin/clang-tidy+0x217d15a)
#1 0x000000000217b17c llvm::sys::RunSignalHandlers() (/llvm-project/build/bin/clang-tidy+0x217b17c)
#2 0x000000000217b2e3 SignalHandler(int) (/llvm-project/build/bin/clang-tidy+0x217b2e3)
#3 0x00007f39be5b1390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#4 0x0000000000593532 clang::tidy::bugprone::BadSignalToKillThreadCheck::check(clang::ast_matchers::MatchFinder::MatchResult const&) (/llvm-project/build/bin/clang-tidy+0x593532)
```
Reviewed By: hokein
Differential Revision: https://reviews.llvm.org/D85401
2020-08-06 10:28:20 +03:00
Nathan James
860aefd078
[clang-tidy][NFC] Remove unnecessary includes throughout clang-tidy header files
...
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D82661
2020-06-29 16:05:52 +01:00
Abel Kocsis
8d288a0668
[clang-tidy] Add bugprone-bad-signal-to-kill-thread check and its alias cert-pos44-c
2019-11-11 17:47:14 +01:00
Abel Kocsis
8cec7e0208
Revert "[clang-tidy] Add bugprone-bad-signal-to-kill-thread checker and alias cert-pos44-c"
...
This reverts commit 4edf0cb0e0
.
2019-11-11 17:34:04 +01:00
Abel Kocsis
4edf0cb0e0
[clang-tidy] Add bugprone-bad-signal-to-kill-thread checker and alias cert-pos44-c
2019-11-11 17:26:44 +01:00