Skip to content

Commit 4f0cc10

Browse files
committed
[NFC][clang-tidy] use hasOperands in place of hasEitherOperand
1 parent 709c52b commit 4f0cc10

File tree

8 files changed

+45
-45
lines changed

8 files changed

+45
-45
lines changed

clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ void StringFindStartswithCheck::registerMatchers(MatchFinder *Finder) {
5252
// Match [=!]= with a zero on one side and a string.find on the other.
5353
binaryOperator(
5454
hasAnyOperatorName("==", "!="),
55-
hasEitherOperand(ignoringParenImpCasts(ZeroLiteral)),
56-
hasEitherOperand(ignoringParenImpCasts(StringFind.bind("findexpr"))))
55+
hasOperands(ignoringParenImpCasts(ZeroLiteral),
56+
ignoringParenImpCasts(StringFind.bind("findexpr"))))
5757
.bind("expr"),
5858
this);
5959
}

clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ void SizeofExpressionCheck::registerMatchers(MatchFinder *Finder) {
163163
if (WarnOnSizeOfCompareToConstant) {
164164
Finder->addMatcher(
165165
binaryOperator(matchers::isRelationalOperator(),
166-
hasEitherOperand(ignoringParenImpCasts(SizeOfExpr)),
167-
hasEitherOperand(ignoringParenImpCasts(
168-
anyOf(integerLiteral(equals(0)),
169-
integerLiteral(isBiggerThan(0x80000))))))
166+
hasOperands(ignoringParenImpCasts(SizeOfExpr),
167+
ignoringParenImpCasts(anyOf(
168+
integerLiteral(equals(0)),
169+
integerLiteral(isBiggerThan(0x80000))))))
170170
.bind("sizeof-compare-constant"),
171171
this);
172172
}
@@ -205,10 +205,11 @@ void SizeofExpressionCheck::registerMatchers(MatchFinder *Finder) {
205205

206206
Finder->addMatcher(
207207
binaryOperator(hasOperatorName("*"),
208-
hasEitherOperand(ignoringParenImpCasts(SizeOfExpr)),
209-
hasEitherOperand(ignoringParenImpCasts(binaryOperator(
210-
hasOperatorName("*"),
211-
hasEitherOperand(ignoringParenImpCasts(SizeOfExpr))))))
208+
hasOperands(ignoringParenImpCasts(SizeOfExpr),
209+
ignoringParenImpCasts(binaryOperator(
210+
hasOperatorName("*"),
211+
hasEitherOperand(
212+
ignoringParenImpCasts(SizeOfExpr))))))
212213
.bind("sizeof-multiply-sizeof"),
213214
this);
214215

@@ -232,12 +233,12 @@ void SizeofExpressionCheck::registerMatchers(MatchFinder *Finder) {
232233
Finder->addMatcher(
233234
binaryOperator(
234235
hasAnyOperatorName("==", "!=", "<", "<=", ">", ">=", "+", "-"),
235-
hasEitherOperand(expr(anyOf(
236-
ignoringParenImpCasts(SizeOfExpr),
237-
ignoringParenImpCasts(binaryOperator(
238-
hasOperatorName("*"),
239-
hasEitherOperand(ignoringParenImpCasts(SizeOfExpr))))))),
240-
hasEitherOperand(ignoringParenImpCasts(PtrDiffExpr)))
236+
hasOperands(expr(anyOf(ignoringParenImpCasts(SizeOfExpr),
237+
ignoringParenImpCasts(binaryOperator(
238+
hasOperatorName("*"),
239+
hasEitherOperand(
240+
ignoringParenImpCasts(SizeOfExpr)))))),
241+
ignoringParenImpCasts(PtrDiffExpr)))
241242
.bind("sizeof-in-ptr-arithmetic-mul"),
242243
this);
243244

clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@ void SuspiciousEnumUsageCheck::registerMatchers(MatchFinder *Finder) {
139139
this);
140140

141141
Finder->addMatcher(
142-
binaryOperator(hasAnyOperatorName("+", "|"),
143-
hasEitherOperand(
144-
expr(hasType(isInteger()), unless(enumExpr("", "")))),
145-
hasEitherOperand(enumExpr("enumExpr", "enumDecl"))),
142+
binaryOperator(
143+
hasAnyOperatorName("+", "|"),
144+
hasOperands(expr(hasType(isInteger()), unless(enumExpr("", ""))),
145+
enumExpr("enumExpr", "enumDecl"))),
146146
this);
147147

148148
Finder->addMatcher(binaryOperator(hasAnyOperatorName("|=", "+="),

clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,11 @@ void SuspiciousStringCompareCheck::registerMatchers(MatchFinder *Finder) {
156156
has(ignoringParenImpCasts(integerLiteral(unless(equals(0)))))),
157157
characterLiteral(), cxxBoolLiteral()));
158158

159-
Finder->addMatcher(binaryOperator(isComparisonOperator(),
160-
hasEitherOperand(StringCompareCallExpr),
161-
hasEitherOperand(InvalidLiteral))
162-
.bind("invalid-comparison"),
163-
this);
159+
Finder->addMatcher(
160+
binaryOperator(isComparisonOperator(),
161+
hasOperands(StringCompareCallExpr, InvalidLiteral))
162+
.bind("invalid-comparison"),
163+
this);
164164
}
165165

166166
void SuspiciousStringCompareCheck::check(

clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,8 @@ static ast_matchers::internal::Matcher<Expr>
533533
matchBinOpIntegerConstantExpr(StringRef Id) {
534534
const auto BinOpCstExpr =
535535
expr(anyOf(binaryOperator(hasAnyOperatorName("+", "|", "&"),
536-
hasEitherOperand(matchSymbolicExpr(Id)),
537-
hasEitherOperand(matchIntegerConstantExpr(Id))),
536+
hasOperands(matchSymbolicExpr(Id),
537+
matchIntegerConstantExpr(Id))),
538538
binaryOperator(hasOperatorName("-"),
539539
hasLHS(matchSymbolicExpr(Id)),
540540
hasRHS(matchIntegerConstantExpr(Id)))))
@@ -900,13 +900,14 @@ void RedundantExpressionCheck::registerMatchers(MatchFinder *Finder) {
900900

901901
// Match expressions like: (X << 8) & 0xFF
902902
Finder->addMatcher(
903-
binaryOperator(hasOperatorName("&"),
904-
hasEitherOperand(ignoringParenImpCasts(binaryOperator(
905-
hasOperatorName("<<"),
906-
hasRHS(ignoringParenImpCasts(
907-
integerLiteral().bind("shift-const")))))),
908-
hasEitherOperand(ignoringParenImpCasts(
909-
integerLiteral().bind("and-const"))))
903+
binaryOperator(
904+
hasOperatorName("&"),
905+
hasOperands(
906+
ignoringParenImpCasts(
907+
binaryOperator(hasOperatorName("<<"),
908+
hasRHS(ignoringParenImpCasts(
909+
integerLiteral().bind("shift-const"))))),
910+
ignoringParenImpCasts(integerLiteral().bind("and-const"))))
910911
.bind("left-right-shift-confusion"),
911912
this);
912913

@@ -923,8 +924,7 @@ void RedundantExpressionCheck::registerMatchers(MatchFinder *Finder) {
923924

924925
// Match expressions like: x <op> 0xFF == 0xF00.
925926
Finder->addMatcher(binaryOperator(isComparisonOperator(),
926-
hasEitherOperand(BinOpCstLeft),
927-
hasEitherOperand(CstRight))
927+
hasOperands(BinOpCstLeft, CstRight))
928928
.bind("binop-const-compare-to-const"),
929929
this);
930930

clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ void DeleteNullPointerCheck::registerMatchers(MatchFinder *Finder) {
3535

3636
const auto PointerCondition = castExpr(hasCastKind(CK_PointerToBoolean),
3737
hasSourceExpression(PointerExpr));
38-
const auto BinaryPointerCheckCondition =
39-
binaryOperator(hasEitherOperand(castExpr(hasCastKind(CK_NullToPointer))),
40-
hasEitherOperand(PointerExpr));
38+
const auto BinaryPointerCheckCondition = binaryOperator(
39+
hasOperands(castExpr(hasCastKind(CK_NullToPointer)), PointerExpr));
4140

4241
Finder->addMatcher(
4342
ifStmt(hasCondition(anyOf(PointerCondition, BinaryPointerCheckCondition)),

clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ void registerMatchersForGetEquals(MatchFinder *Finder,
8282
// Matches against nullptr.
8383
Finder->addMatcher(
8484
binaryOperator(hasAnyOperatorName("==", "!="),
85-
hasEitherOperand(ignoringImpCasts(
86-
anyOf(cxxNullPtrLiteralExpr(), gnuNullExpr(),
87-
integerLiteral(equals(0))))),
88-
hasEitherOperand(callToGet(knownSmartptr()))),
85+
hasOperands(ignoringImpCasts(anyOf(
86+
cxxNullPtrLiteralExpr(), gnuNullExpr(),
87+
integerLiteral(equals(0)))),
88+
callToGet(knownSmartptr()))),
8989
Callback);
9090

9191
// FIXME: Match and fix if (l.get() == r.get()).

clang-tools-extra/clang-tidy/readability/StringCompareCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ void StringCompareCheck::registerMatchers(MatchFinder *Finder) {
3939
// Third and fourth case: str.compare(str) == 0 and str.compare(str) != 0.
4040
Finder->addMatcher(
4141
binaryOperator(hasAnyOperatorName("==", "!="),
42-
hasEitherOperand(StrCompare.bind("compare")),
43-
hasEitherOperand(integerLiteral(equals(0)).bind("zero")))
42+
hasOperands(StrCompare.bind("compare"),
43+
integerLiteral(equals(0)).bind("zero")))
4444
.bind("match2"),
4545
this);
4646
}

0 commit comments

Comments
 (0)