[clang-format][NFC] Use `empty()` instead of comparing size() to 0 or 1
diff --git a/clang/lib/Format/FormatTokenLexer.cpp b/clang/lib/Format/FormatTokenLexer.cpp index 05dee26..40b62b2 100644 --- a/clang/lib/Format/FormatTokenLexer.cpp +++ b/clang/lib/Format/FormatTokenLexer.cpp
@@ -488,7 +488,7 @@ // In C# transform identifier foreach into kw_foreach bool FormatTokenLexer::tryTransformCSharpForEach() { - if (Tokens.size() < 1) + if (Tokens.empty()) return false; auto &Identifier = *(Tokens.end() - 1); if (Identifier->isNot(tok::identifier)) @@ -948,7 +948,7 @@ // 4. The first non-digit character is 'x', and the next is a hex digit. // Note that in the case 3 and 4, if the next character does not exists in // this token, the token is an identifier. - if (Text.size() < 1 || Text[0] == '+' || Text[0] == '-') + if (Text.empty() || Text[0] == '+' || Text[0] == '-') return; const auto NonDigitPos = Text.find_if([](char C) { return !isdigit(C); }); // All the characters are digits
diff --git a/clang/lib/Format/MacroExpander.cpp b/clang/lib/Format/MacroExpander.cpp index 37c25e6..85a53c9 100644 --- a/clang/lib/Format/MacroExpander.cpp +++ b/clang/lib/Format/MacroExpander.cpp
@@ -226,7 +226,7 @@ New->MacroCtx = MacroExpansion(MR_Hidden); pushToken(New); } - assert(Result.size() >= 1 && Result.back()->is(tok::eof)); + assert(!Result.empty() && Result.back()->is(tok::eof)); if (Result.size() > 1) { ++Result[0]->MacroCtx->StartOfExpansion; ++Result[Result.size() - 2]->MacroCtx->EndOfExpansion;
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index c961ce7..7e8634a 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -4601,7 +4601,7 @@ } else { // At the top level we only get here when no unexpansion is going on, or // when conditional formatting led to unfinished macro reconstructions. - assert(!Reconstruct || (CurrentLines != &Lines) || PPStack.size() > 0); + assert(!Reconstruct || (CurrentLines != &Lines) || !PPStack.empty()); CurrentLines->push_back(std::move(*Line)); } Line->Tokens.clear();