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();
|
parseConcept();
|
||||||
return;
|
return;
|
||||||
case tok::kw_requires: {
|
case tok::kw_requires: {
|
||||||
|
if (Style.isCpp()) {
|
||||||
bool ParsedClause = parseRequires();
|
bool ParsedClause = parseRequires();
|
||||||
if (ParsedClause)
|
if (ParsedClause)
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
nextToken();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case tok::kw_enum:
|
case tok::kw_enum:
|
||||||
|
|
|
@ -323,6 +323,7 @@ TEST_F(FormatTestJS, ReservedWords) {
|
||||||
verifyFormat("var struct = 2;");
|
verifyFormat("var struct = 2;");
|
||||||
verifyFormat("var union = 2;");
|
verifyFormat("var union = 2;");
|
||||||
verifyFormat("var interface = 2;");
|
verifyFormat("var interface = 2;");
|
||||||
|
verifyFormat("var requires = {};");
|
||||||
verifyFormat("interface = 2;");
|
verifyFormat("interface = 2;");
|
||||||
verifyFormat("x = interface instanceof y;");
|
verifyFormat("x = interface instanceof y;");
|
||||||
verifyFormat("interface Test {\n"
|
verifyFormat("interface Test {\n"
|
||||||
|
|
Loading…
Reference in New Issue