[PATCH] D120324: [clang-format] Avoid parsing "requires" as a keyword in non-C++-like languages.
Marek Kurdej via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 22 07:55:53 PST 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG071f870e7ff0: [clang-format] Avoid parsing "requires" as a keyword in non-C++-like languages. (authored by curdeius).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120324/new/
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
@@ -1563,9 +1563,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:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120324.410537.patch
Type: text/x-patch
Size: 1087 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220222/ddb489ff/attachment.bin>
More information about the cfe-commits
mailing list