[clang-tools-extra] r355702 - [clang-tidy] NFC: Negate the name and semantics of the isNotInMacro function.
Hyrum Wright via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 8 07:37:15 PST 2019
Author: hwright
Date: Fri Mar 8 07:37:15 2019
New Revision: 355702
URL: http://llvm.org/viewvc/llvm-project?rev=355702&view=rev
Log:
[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.
Modified:
clang-tools-extra/trunk/clang-tidy/abseil/DurationComparisonCheck.cpp
clang-tools-extra/trunk/clang-tidy/abseil/DurationConversionCastCheck.cpp
clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp
clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.h
clang-tools-extra/trunk/clang-tidy/abseil/DurationUnnecessaryConversionCheck.cpp
Modified: clang-tools-extra/trunk/clang-tidy/abseil/DurationComparisonCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/DurationComparisonCheck.cpp?rev=355702&r1=355701&r2=355702&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/abseil/DurationComparisonCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/DurationComparisonCheck.cpp Fri Mar 8 07:37:15 2019
@@ -43,8 +43,7 @@ void DurationComparisonCheck::check(cons
// 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());
Modified: clang-tools-extra/trunk/clang-tidy/abseil/DurationConversionCastCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/DurationConversionCastCheck.cpp?rev=355702&r1=355701&r2=355702&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/abseil/DurationConversionCastCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/DurationConversionCastCheck.cpp Fri Mar 8 07:37:15 2019
@@ -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");
Modified: clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp?rev=355702&r1=355701&r2=355702&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp Fri Mar 8 07:37:15 2019
@@ -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::Mat
// 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
Modified: clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.h?rev=355702&r1=355701&r2=355702&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.h (original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.h Fri Mar 8 07:37:15 2019
@@ -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) {
Modified: clang-tools-extra/trunk/clang-tidy/abseil/DurationUnnecessaryConversionCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/DurationUnnecessaryConversionCheck.cpp?rev=355702&r1=355701&r2=355702&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/abseil/DurationUnnecessaryConversionCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/DurationUnnecessaryConversionCheck.cpp Fri Mar 8 07:37:15 2019
@@ -44,7 +44,7 @@ void DurationUnnecessaryConversionCheck:
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")
More information about the cfe-commits
mailing list