[clang] 511662b - [clang-format][NFC] Don't call startsSequence() in the parser

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Sat Sep 30 02:14:27 PDT 2023


Author: Owen Pan
Date: 2023-09-30T02:09:52-07:00
New Revision: 511662b88c36f8d5d02f0b758b15c1b84d4ee6c1

URL: https://github.com/llvm/llvm-project/commit/511662b88c36f8d5d02f0b758b15c1b84d4ee6c1
DIFF: https://github.com/llvm/llvm-project/commit/511662b88c36f8d5d02f0b758b15c1b84d4ee6c1.diff

LOG: [clang-format][NFC] Don't call startsSequence() in the parser

It always returns false in the unwrapped line parser!

Added: 
    

Modified: 
    clang/lib/Format/UnwrappedLineParser.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 336e23dc6ff6aee..bf38ed73c4a0b4e 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -2278,8 +2278,7 @@ bool UnwrappedLineParser::tryToParseLambdaIntroducer() {
 }
 
 void UnwrappedLineParser::tryToParseJSFunction() {
-  assert(FormatTok->is(Keywords.kw_function) ||
-         FormatTok->startsSequence(Keywords.kw_async, Keywords.kw_function));
+  assert(FormatTok->is(Keywords.kw_function));
   if (FormatTok->is(Keywords.kw_async))
     nextToken();
   // Consume "function".
@@ -2357,8 +2356,7 @@ bool UnwrappedLineParser::parseBracedList(bool ContinueOnSemicolons,
       continue;
     }
     if (Style.isJavaScript()) {
-      if (FormatTok->is(Keywords.kw_function) ||
-          FormatTok->startsSequence(Keywords.kw_async, Keywords.kw_function)) {
+      if (FormatTok->is(Keywords.kw_function)) {
         tryToParseJSFunction();
         continue;
       }
@@ -2511,14 +2509,10 @@ bool UnwrappedLineParser::parseParens(TokenType AmpAmpTokenType) {
         nextToken();
       break;
     case tok::identifier:
-      if (Style.isJavaScript() &&
-          (FormatTok->is(Keywords.kw_function) ||
-           FormatTok->startsSequence(Keywords.kw_async,
-                                     Keywords.kw_function))) {
+      if (Style.isJavaScript() && (FormatTok->is(Keywords.kw_function)))
         tryToParseJSFunction();
-      } else {
+      else
         nextToken();
-      }
       break;
     case tok::kw_requires: {
       auto RequiresToken = FormatTok;


        


More information about the cfe-commits mailing list