[clang] 3971880 - [clang-format][NFC] Clean up tryToParseLambdaIntroducer()

via cfe-commits cfe-commits at lists.llvm.org
Tue May 3 11:36:47 PDT 2022


Author: owenca
Date: 2022-05-03T11:36:38-07:00
New Revision: 397188036d4cdec7c3bc9236b4a5197232283413

URL: https://github.com/llvm/llvm-project/commit/397188036d4cdec7c3bc9236b4a5197232283413
DIFF: https://github.com/llvm/llvm-project/commit/397188036d4cdec7c3bc9236b4a5197232283413.diff

LOG: [clang-format][NFC] Clean up tryToParseLambdaIntroducer()

Differential Revision: https://reviews.llvm.org/D124818

Added: 
    

Modified: 
    clang/lib/Format/UnwrappedLineParser.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 520f73ac15eeb..52ce0fff251c2 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -1931,11 +1931,11 @@ bool UnwrappedLineParser::tryToParsePropertyAccessor() {
 }
 
 bool UnwrappedLineParser::tryToParseLambda() {
+  assert(FormatTok->is(tok::l_square));
   if (!Style.isCpp()) {
     nextToken();
     return false;
   }
-  assert(FormatTok->is(tok::l_square));
   FormatToken &LSquare = *FormatTok;
   if (!tryToParseLambdaIntroducer())
     return false;
@@ -2037,20 +2037,20 @@ bool UnwrappedLineParser::tryToParseLambda() {
 
 bool UnwrappedLineParser::tryToParseLambdaIntroducer() {
   const FormatToken *Previous = FormatTok->Previous;
+  const FormatToken *LeftSquare = FormatTok;
+  nextToken();
   if (Previous &&
       (Previous->isOneOf(tok::identifier, tok::kw_operator, tok::kw_new,
                          tok::kw_delete, tok::l_square) ||
-       FormatTok->isCppStructuredBinding(Style) || Previous->closesScope() ||
+       LeftSquare->isCppStructuredBinding(Style) || Previous->closesScope() ||
        Previous->isSimpleTypeSpecifier())) {
-    nextToken();
     return false;
   }
-  nextToken();
   if (FormatTok->is(tok::l_square))
     return false;
   if (FormatTok->is(tok::r_square)) {
     const FormatToken *Next = Tokens->peekNextToken();
-    if (Next && Next->is(tok::greater))
+    if (Next->is(tok::greater))
       return false;
   }
   parseSquare(/*LambdaIntroducer=*/true);


        


More information about the cfe-commits mailing list