diff options
author | Hyrum Wright <hwright@google.com> | 2019-03-08 15:37:15 +0000 |
---|---|---|
committer | Hyrum Wright <hwright@google.com> | 2019-03-08 15:37:15 +0000 |
commit | 8172a0a5f4a8110cc2cb18b1389e9b048946644c (patch) | |
tree | 7055fc4f50de1bd407cad515b22bcdd4e0af44ab | |
parent | e73ae9a142c256f52bbae4be8bb0cc254afa8f6f (diff) | |
download | bcm5719-llvm-8172a0a5f4a8110cc2cb18b1389e9b048946644c.tar.gz bcm5719-llvm-8172a0a5f4a8110cc2cb18b1389e9b048946644c.zip |
[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
5 files changed, 9 insertions, 10 deletions
diff --git a/clang-tools-extra/clang-tidy/abseil/DurationComparisonCheck.cpp b/clang-tools-extra/clang-tidy/abseil/DurationComparisonCheck.cpp index 337f2ca0a2e..3b19e5fd053 100644 --- a/clang-tools-extra/clang-tidy/abseil/DurationComparisonCheck.cpp +++ b/clang-tools-extra/clang-tidy/abseil/DurationComparisonCheck.cpp @@ -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()); diff --git a/clang-tools-extra/clang-tidy/abseil/DurationConversionCastCheck.cpp b/clang-tools-extra/clang-tidy/abseil/DurationConversionCastCheck.cpp index f0ae82c0b11..d9e91554210 100644 --- a/clang-tools-extra/clang-tidy/abseil/DurationConversionCastCheck.cpp +++ b/clang-tools-extra/clang-tidy/abseil/DurationConversionCastCheck.cpp @@ -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"); diff --git a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp index ceee2ec8618..3466cdbbdcf 100644 --- a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp +++ b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp @@ -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 diff --git a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.h b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.h index 5b4689f3f08..32f8167cdc2 100644 --- a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.h +++ b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.h @@ -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) { diff --git a/clang-tools-extra/clang-tidy/abseil/DurationUnnecessaryConversionCheck.cpp b/clang-tools-extra/clang-tidy/abseil/DurationUnnecessaryConversionCheck.cpp index 83650cd105d..ae7619972c2 100644 --- a/clang-tools-extra/clang-tidy/abseil/DurationUnnecessaryConversionCheck.cpp +++ b/clang-tools-extra/clang-tidy/abseil/DurationUnnecessaryConversionCheck.cpp @@ -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") |