32 const auto *Binop = Result.Nodes.getNodeAs<clang::BinaryOperator>(
"binop");
33 const auto *Call = Result.Nodes.getNodeAs<clang::CallExpr>(
"call");
36 if (Binop->getExprLoc().isMacroID() || Binop->getExprLoc().isInvalid())
40 Result.Nodes.getNodeAs<clang::FunctionDecl>(
"function_decl")->getName());
47 if (Call == Binop->getLHS()->IgnoreParenImpCasts()) {
48 Hint = FixItHint::CreateReplacement(
49 Binop->getSourceRange(),
50 (llvm::Twine(TimeFactory) +
"(" +
51 tooling::fixit::getText(*Call->getArg(0), *Result.Context) +
" + " +
55 assert(Call == Binop->getRHS()->IgnoreParenImpCasts() &&
56 "Call should be found on the RHS");
57 Hint = FixItHint::CreateReplacement(
58 Binop->getSourceRange(),
59 (llvm::Twine(TimeFactory) +
"(" +
61 " + " + tooling::fixit::getText(*Call->getArg(0), *Result.Context) +
66 diag(Binop->getBeginLoc(),
"perform addition in the duration domain") << Hint;
std::string rewriteExprFromNumberToDuration(const ast_matchers::MatchFinder::MatchResult &Result, DurationScale Scale, const Expr *Node)
Assuming Node has type double or int representing a time interval of Scale, return the expression to ...