54 const MatchFinder::MatchResult &Result) {
55 StringRef RetryMacroName;
56 const auto &Node = *Result.Nodes.getNodeAs<BinaryOperator>(
"outer");
57 if (!Node.getBeginLoc().isMacroID())
60 const SourceManager &SM = *Result.SourceManager;
61 if (!SM.isMacroArgExpansion(Node.getRHS()->IgnoreParenCasts()->getBeginLoc()))
64 const LangOptions &Opts = Result.Context->getLangOpts();
65 SourceLocation LocStart = Node.getBeginLoc();
66 while (LocStart.isMacroID()) {
67 SourceLocation Invocation = SM.getImmediateMacroCallerLoc(LocStart);
69 if (!Lexer::getRawToken(SM.getSpellingLoc(Invocation), Tok, SM, Opts,
71 if (Tok.getKind() == tok::raw_identifier &&
72 llvm::is_contained(RetryMacros, Tok.getRawIdentifier())) {
73 RetryMacroName = Tok.getRawIdentifier();
78 LocStart = Invocation;
80 if (RetryMacroName.empty())
83 const auto &Inner = *Result.Nodes.getNodeAs<BinaryOperator>(
"inner");
84 diag(Inner.getOperatorLoc(),
"top-level comparison in %0") << RetryMacroName;
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.