curdeius created this revision.
curdeius added reviewers: MyDeveloperDay, HazardyKnusperkeks, owenpan, krasimir.
curdeius requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes the issue raised post-review in D113319 
<https://reviews.llvm.org/D113319> (cf. 
https://reviews.llvm.org/D113319#3337485).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120324

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTestJS.cpp


Index: clang/unittests/Format/FormatTestJS.cpp
===================================================================
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -323,6 +323,7 @@
   verifyFormat("var struct = 2;");
   verifyFormat("var union = 2;");
   verifyFormat("var interface = 2;");
+  verifyFormat("var requires = {};");
   verifyFormat("interface = 2;");
   verifyFormat("x = interface instanceof y;");
   verifyFormat("interface Test {\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===================================================================
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1562,9 +1562,13 @@
       parseConcept();
       return;
     case tok::kw_requires: {
-      bool ParsedClause = parseRequires();
-      if (ParsedClause)
-        return;
+      if (Style.isCpp()) {
+        bool ParsedClause = parseRequires();
+        if (ParsedClause)
+          return;
+      } else {
+        nextToken();
+      }
       break;
     }
     case tok::kw_enum:


Index: clang/unittests/Format/FormatTestJS.cpp
===================================================================
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -323,6 +323,7 @@
   verifyFormat("var struct = 2;");
   verifyFormat("var union = 2;");
   verifyFormat("var interface = 2;");
+  verifyFormat("var requires = {};");
   verifyFormat("interface = 2;");
   verifyFormat("x = interface instanceof y;");
   verifyFormat("interface Test {\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===================================================================
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1562,9 +1562,13 @@
       parseConcept();
       return;
     case tok::kw_requires: {
-      bool ParsedClause = parseRequires();
-      if (ParsedClause)
-        return;
+      if (Style.isCpp()) {
+        bool ParsedClause = parseRequires();
+        if (ParsedClause)
+          return;
+      } else {
+        nextToken();
+      }
       break;
     }
     case tok::kw_enum:
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to