Author: owenca Date: 2022-01-20T14:35:07-08:00 New Revision: c95afac89e000b65edc51dc7d05610250a62c86f
URL: https://github.com/llvm/llvm-project/commit/c95afac89e000b65edc51dc7d05610250a62c86f DIFF: https://github.com/llvm/llvm-project/commit/c95afac89e000b65edc51dc7d05610250a62c86f.diff LOG: [clang-format][NFC] Clean up tryMergeLessLess() Differential Revision: https://reviews.llvm.org/D117759 Added: Modified: clang/lib/Format/FormatTokenLexer.cpp Removed: ################################################################################ diff --git a/clang/lib/Format/FormatTokenLexer.cpp b/clang/lib/Format/FormatTokenLexer.cpp index e8b9b3d61c888..c9166f4b17aab 100644 --- a/clang/lib/Format/FormatTokenLexer.cpp +++ b/clang/lib/Format/FormatTokenLexer.cpp @@ -430,25 +430,22 @@ bool FormatTokenLexer::tryMergeLessLess() { return false; auto First = Tokens.end() - 3; - bool FourthTokenIsLess = false; - - if (Tokens.size() > 3) { - auto Fourth = (Tokens.end() - 4)[0]; - FourthTokenIsLess = Fourth->is(tok::less); - - // Do not remove a whitespace between the two "<" e.g. "operator< <>". - if (First[2]->is(tok::greater) && Fourth->is(tok::kw_operator)) - return false; - } - - if (First[2]->is(tok::less) || First[1]->isNot(tok::less) || - First[0]->isNot(tok::less) || FourthTokenIsLess) + if (First[0]->isNot(tok::less) || First[1]->isNot(tok::less)) return false; // Only merge if there currently is no whitespace between the two "<". if (First[1]->hasWhitespaceBefore()) return false; + auto X = Tokens.size() > 3 ? First[-1] : nullptr; + auto Y = First[2]; + if ((X && X->is(tok::less)) || Y->is(tok::less)) + return false; + + // Do not remove a whitespace between the two "<" e.g. "operator< <>". + if (X && X->is(tok::kw_operator) && Y->is(tok::greater)) + return false; + First[0]->Tok.setKind(tok::lessless); First[0]->TokenText = "<<"; First[0]->ColumnWidth += 1; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits