summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-11-20 15:58:50 +0000
committerDaniel Jasper <djasper@google.com>2015-11-20 15:58:50 +0000
commit09840efd92cca6713fd0e71543b21d201da636d6 (patch)
tree49923c8c6d14a62e526707b6c9ffd39bd5497a9e
parentdf544a098aa63aca5c1830ac1cfd19fbdb5b9f7f (diff)
downloadbcm5719-llvm-09840efd92cca6713fd0e71543b21d201da636d6.tar.gz
bcm5719-llvm-09840efd92cca6713fd0e71543b21d201da636d6.zip
clang-format: [JS] struct and union aren't keywords / reserved words.
llvm-svn: 253671
-rw-r--r--clang/lib/Format/Format.cpp4
-rw-r--r--clang/unittests/Format/FormatTestJS.cpp2
2 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 4bc12f88cb0..e7e71c4c7e3 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -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);
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index b491cd58659..9be375243c8 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -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) {
OpenPOWER on IntegriCloud