forked from OSchip/llvm-project
[clang-format] Avoid parsing "requires" as a keyword in non-C++-like languages.
Fixes the issue raised post-review in D113319 (cf. https://reviews.llvm.org/D113319#3337485). Reviewed By: krasimir Differential Revision: https://reviews.llvm.org/D120324
This commit is contained in:
parent
2aaba44b5c
commit
071f870e7f
|
@ -1563,9 +1563,13 @@ void UnwrappedLineParser::parseStructuralElement(IfStmtKind *IfKind,
|
|||
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:
|
||||
|
|
|
@ -323,6 +323,7 @@ TEST_F(FormatTestJS, ReservedWords) {
|
|||
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"
|
||||
|
|
Loading…
Reference in New Issue