12 #include "clang/AST/ASTContext.h"
13 #include "clang/ASTMatchers/ASTMatchFinder.h"
14 #include "clang/Tooling/FixIt.h"
22 void TimeComparisonCheck::registerMatchers(MatchFinder *Finder) {
24 expr(comparisonOperatorWithCallee(functionDecl(
25 functionDecl(TimeConversionFunction()).bind(
"function_decl"))))
28 Finder->addMatcher(Matcher,
this);
31 void TimeComparisonCheck::check(
const MatchFinder::MatchResult &Result) {
32 const auto *Binop = Result.Nodes.getNodeAs<BinaryOperator>(
"binop");
35 Result.Nodes.getNodeAs<FunctionDecl>(
"function_decl")->getName());
46 std::string LhsReplacement =
48 std::string RhsReplacement =
51 diag(Binop->getBeginLoc(),
"perform comparison in the time domain")
52 << FixItHint::CreateReplacement(Binop->getSourceRange(),
53 (llvm::Twine(LhsReplacement) +
" " +
54 Binop->getOpcodeStr() +
" " +