diff options
author | Owen Pan <owenpiano@gmail.com> | 2025-07-06 14:19:30 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-06 14:19:30 -0700 |
commit | 5ccbea9f480d5c387c7f21aa101e72774c91f1d3 (patch) | |
tree | 165b015ba243551f9b126d22a5865f788e692abc /clang/lib/Format/FormatTokenLexer.cpp | |
parent | 6a9a16da7a380e18b996bb6573eeb18b913204fc (diff) | |
download | llvm-5ccbea9f480d5c387c7f21aa101e72774c91f1d3.zip llvm-5ccbea9f480d5c387c7f21aa101e72774c91f1d3.tar.gz llvm-5ccbea9f480d5c387c7f21aa101e72774c91f1d3.tar.bz2 |
[clang-format][NFC] Replace size() with empty() (#147164)
Diffstat (limited to 'clang/lib/Format/FormatTokenLexer.cpp')
-rw-r--r-- | clang/lib/Format/FormatTokenLexer.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/clang/lib/Format/FormatTokenLexer.cpp b/clang/lib/Format/FormatTokenLexer.cpp index 06f68ec..05dee26 100644 --- a/clang/lib/Format/FormatTokenLexer.cpp +++ b/clang/lib/Format/FormatTokenLexer.cpp @@ -1371,8 +1371,7 @@ FormatToken *FormatTokenLexer::getNextToken() { } else if (FormatTok->TokenText == "``") { FormatTok->Tok.setIdentifierInfo(nullptr); FormatTok->Tok.setKind(tok::hashhash); - } else if (Tokens.size() > 0 && - Tokens.back()->is(Keywords.kw_apostrophe) && + } else if (!Tokens.empty() && Tokens.back()->is(Keywords.kw_apostrophe) && NumberBase.match(FormatTok->TokenText, &Matches)) { // In Verilog in a based number literal like `'b10`, there may be // whitespace between `'b` and `10`. Therefore we handle the base and @@ -1420,7 +1419,7 @@ FormatToken *FormatTokenLexer::getNextToken() { tryParseJavaTextBlock(); } - if (Style.isVerilog() && Tokens.size() > 0 && + if (Style.isVerilog() && !Tokens.empty() && Tokens.back()->is(TT_VerilogNumberBase) && FormatTok->Tok.isOneOf(tok::identifier, tok::question)) { // Mark the number following a base like `'h?a0` as a number. @@ -1454,9 +1453,9 @@ FormatToken *FormatTokenLexer::getNextToken() { if (Style.isCpp()) { auto *Identifier = FormatTok->Tok.getIdentifierInfo(); auto it = Macros.find(Identifier); - if (!(Tokens.size() > 0 && Tokens.back()->Tok.getIdentifierInfo() && - Tokens.back()->Tok.getIdentifierInfo()->getPPKeywordID() == - tok::pp_define) && + if ((Tokens.empty() || !Tokens.back()->Tok.getIdentifierInfo() || + Tokens.back()->Tok.getIdentifierInfo()->getPPKeywordID() != + tok::pp_define) && it != Macros.end()) { FormatTok->setType(it->second); if (it->second == TT_IfMacro) { |