Skip to content

Commit 3b5a121

Browse files
authored
[clang-tidy][NFC] replace comparison of begin and end iterators with range empty (#91994)
Improves readability by changing comparisons of `*_begin` and `*_end` iterators into `.empty()` on their range.
1 parent 398162d commit 3b5a121

File tree

4 files changed

+4
-8
lines changed

4 files changed

+4
-8
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,7 @@ void SuspiciousEnumUsageCheck::check(const MatchFinder::MatchResult &Result) {
171171
// Skip when one of the parameters is an empty enum. The
172172
// hasDisjointValueRange function could not decide the values properly in
173173
// case of an empty enum.
174-
if (EnumDec->enumerator_begin() == EnumDec->enumerator_end() ||
175-
OtherEnumDec->enumerator_begin() == OtherEnumDec->enumerator_end())
174+
if (EnumDec->enumerators().empty() || OtherEnumDec->enumerators().empty())
176175
return;
177176

178177
if (!hasDisjointValueRange(EnumDec, OtherEnumDec))

clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ static std::string createReplacementText(const LambdaExpr *Lambda) {
6767
AppendName("this");
6868
}
6969
}
70-
if (!Replacement.empty() &&
71-
Lambda->explicit_capture_begin() != Lambda->explicit_capture_end()) {
70+
if (!Replacement.empty() && !Lambda->explicit_captures().empty()) {
7271
// Add back separator if we are adding explicit capture variables.
7372
Stream << ", ";
7473
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,7 @@ void UnusedParametersCheck::check(const MatchFinder::MatchResult &Result) {
192192

193193
// In non-strict mode ignore function definitions with empty bodies
194194
// (constructor initializer counts for non-empty body).
195-
if (StrictMode ||
196-
(Function->getBody()->child_begin() !=
197-
Function->getBody()->child_end()) ||
195+
if (StrictMode || !Function->getBody()->children().empty() ||
198196
(isa<CXXConstructorDecl>(Function) &&
199197
cast<CXXConstructorDecl>(Function)->getNumCtorInitializers() > 0))
200198
warnOnUnusedParameter(Result, Function, I);

clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ findInsertionForConstraint(const FunctionDecl *Function, ASTContext &Context) {
254254
return utils::lexer::findPreviousTokenKind(Init->getSourceLocation(),
255255
SM, LangOpts, tok::colon);
256256
}
257-
if (Constructor->init_begin() != Constructor->init_end())
257+
if (!Constructor->inits().empty())
258258
return std::nullopt;
259259
}
260260
if (Function->isDeleted()) {

0 commit comments

Comments
 (0)