clang-format: [JS] struct and union aren't keywords / reserved words.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@253671 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Jasper 2015-11-20 15:58:50 +00:00
parent aaf49845dc
commit 36d78064b0
2 changed files with 6 additions and 0 deletions

View File

@ -1245,6 +1245,10 @@ private:
FormatTok->isOneOf(tok::kw_struct, tok::kw_union, tok::kw_delete)) {
FormatTok->Tok.setKind(tok::identifier);
FormatTok->Tok.setIdentifierInfo(nullptr);
} else if (Style.Language == FormatStyle::LK_JavaScript &&
FormatTok->isOneOf(tok::kw_struct, tok::kw_union)) {
FormatTok->Tok.setKind(tok::identifier);
FormatTok->Tok.setIdentifierInfo(nullptr);
}
} else if (FormatTok->Tok.is(tok::greatergreater)) {
FormatTok->Tok.setKind(tok::greater);

View File

@ -111,6 +111,8 @@ TEST_F(FormatTestJS, ReservedWords) {
" interface: 1,\n"
" switch: 1,\n"
"};");
verifyFormat("var struct = 2;");
verifyFormat("var union = 2;");
}
TEST_F(FormatTestJS, ES6DestructuringAssignment) {