// want to handle the case of rewriting both sides. This is much simpler if
// we unconditionally try and rewrite both, and let the rewriter determine
// if nothing needs to be done.
- if (!isNotInMacro(Result, Binop->getLHS()) ||
- !isNotInMacro(Result, Binop->getRHS()))
+ if (isInMacro(Result, Binop->getLHS()) || isInMacro(Result, Binop->getRHS()))
return;
std::string LhsReplacement =
rewriteExprFromNumberToDuration(Result, *Scale, Binop->getLHS());
const auto *MatchedCast =
Result.Nodes.getNodeAs<ExplicitCastExpr>("cast_expr");
- if (!isNotInMacro(Result, MatchedCast))
+ if (isInMacro(Result, MatchedCast))
return;
const auto *FuncDecl = Result.Nodes.getNodeAs<FunctionDecl>("func_decl");
.str();
}
-bool isNotInMacro(const MatchFinder::MatchResult &Result, const Expr *E) {
+bool isInMacro(const MatchFinder::MatchResult &Result, const Expr *E) {
if (!E->getBeginLoc().isMacroID())
- return true;
+ return false;
SourceLocation Loc = E->getBeginLoc();
// We want to get closer towards the initial macro typed into the source only
// because Clang comment says it "should not generally be used by clients."
Loc = Result.SourceManager->getImmediateMacroCallerLoc(Loc);
}
- return !Loc.isMacroID();
+ return Loc.isMacroID();
}
} // namespace abseil
const ast_matchers::MatchFinder::MatchResult &Result, DurationScale Scale,
const Expr *Node);
-/// Return `true` if `E` is a either: not a macro at all; or an argument to
+/// Return `false` if `E` is a either: not a macro at all; or an argument to
/// one. In the both cases, we often want to do the transformation.
-bool isNotInMacro(const ast_matchers::MatchFinder::MatchResult &Result,
- const Expr *E);
+bool isInMacro(const ast_matchers::MatchFinder::MatchResult &Result,
+ const Expr *E);
AST_MATCHER_FUNCTION(ast_matchers::internal::Matcher<FunctionDecl>,
DurationConversionFunction) {
const auto *OuterCall = Result.Nodes.getNodeAs<Expr>("call");
const auto *Arg = Result.Nodes.getNodeAs<Expr>("arg");
- if (!isNotInMacro(Result, OuterCall))
+ if (isInMacro(Result, OuterCall))
return;
diag(OuterCall->getBeginLoc(), "remove unnecessary absl::Duration conversions")