[clang-tidy] NFC: Negate the name and semantics of the isNotInMacro function.

This function is always used in a context where its result was also
negated, which made for confusing naming and code.

llvm-svn: 355702
This commit is contained in:
Hyrum Wright 2019-03-08 15:37:15 +00:00
parent e73ae9a142
commit 8172a0a5f4
5 changed files with 9 additions and 10 deletions

View File

@ -43,8 +43,7 @@ void DurationComparisonCheck::check(const MatchFinder::MatchResult &Result) {
// 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());

View File

@ -37,7 +37,7 @@ void DurationConversionCastCheck::check(
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");

View File

@ -302,9 +302,9 @@ std::string rewriteExprFromNumberToTime(
.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
@ -316,7 +316,7 @@ bool isNotInMacro(const MatchFinder::MatchResult &Result, const Expr *E) {
// 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

View File

@ -91,10 +91,10 @@ std::string rewriteExprFromNumberToTime(
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) {

View File

@ -44,7 +44,7 @@ void DurationUnnecessaryConversionCheck::check(
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")