31 const auto IsSigterm = [](
const auto &KeyValue) ->
bool {
32 return KeyValue.first->getName() ==
"SIGTERM" &&
33 KeyValue.first->hasMacroDefinition();
35 const auto TryExpandAsInteger =
36 [](Preprocessor::macro_iterator It) -> std::optional<unsigned> {
37 if (It ==
PP->macro_end())
39 const MacroInfo *MI =
PP->getMacroInfo(It->first);
40 const Token &T = MI->tokens().back();
45 SmallVector<char> Buffer;
47 const StringRef ValueStr =
PP->getSpelling(T, Buffer, &Invalid);
52 constexpr unsigned AutoSenseRadix = 0;
53 if (ValueStr.getAsInteger(AutoSenseRadix, IntValue))
55 return IntValue.getZExtValue();
58 const auto SigtermMacro = llvm::find_if(
PP->macros(), IsSigterm);
63 const auto *MatchedExpr = Result.Nodes.getNodeAs<Expr>(
"thread-kill");
64 const auto *MatchedIntLiteral =
65 Result.Nodes.getNodeAs<IntegerLiteral>(
"integer-literal");
67 diag(MatchedExpr->getBeginLoc(),
68 "thread should not be terminated by raising the 'SIGTERM' signal");