summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-12-22 15:47:56 +0000
committerDaniel Jasper <djasper@google.com>2015-12-22 15:47:56 +0000
commit72a1b6a5f245509e45fa9e01e1fbc4a917c51fd4 (patch)
tree789fe55d47bcac2f7765c97329b60fb0ba137111
parentcfcdbde3ce1ef6ccd97e2fdc45ad074b7f63de0d (diff)
downloadbcm5719-llvm-72a1b6a5f245509e45fa9e01e1fbc4a917c51fd4.tar.gz
bcm5719-llvm-72a1b6a5f245509e45fa9e01e1fbc4a917c51fd4.zip
clang-format: [JS] "operator" is not a keyword in Java/JavaScript.
llvm-svn: 256245
-rw-r--r--clang/lib/Format/Format.cpp6
-rw-r--r--clang/unittests/Format/FormatTestJS.cpp5
-rw-r--r--clang/unittests/Format/FormatTestJava.cpp1
3 files changed, 10 insertions, 2 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index d86fccf416e..c7d1abd2b24 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1274,11 +1274,13 @@ private:
FormatTok->Tok.setIdentifierInfo(&Info);
FormatTok->Tok.setKind(Info.getTokenID());
if (Style.Language == FormatStyle::LK_Java &&
- FormatTok->isOneOf(tok::kw_struct, tok::kw_union, tok::kw_delete)) {
+ FormatTok->isOneOf(tok::kw_struct, tok::kw_union, tok::kw_delete,
+ tok::kw_operator)) {
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->isOneOf(tok::kw_struct, tok::kw_union,
+ tok::kw_operator)) {
FormatTok->Tok.setKind(tok::identifier);
FormatTok->Tok.setIdentifierInfo(nullptr);
}
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index fdcc0b75ad3..0957759397f 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -115,6 +115,11 @@ TEST_F(FormatTestJS, ReservedWords) {
verifyFormat("var union = 2;");
}
+TEST_F(FormatTestJS, CppKeywords) {
+ // Make sure we don't mess stuff up because of C++ keywords.
+ verifyFormat("return operator && (aa);");
+}
+
TEST_F(FormatTestJS, ES6DestructuringAssignment) {
verifyFormat("var [a, b, c] = [1, 2, 3];");
verifyFormat("let [a, b, c] = [1, 2, 3];");
diff --git a/clang/unittests/Format/FormatTestJava.cpp b/clang/unittests/Format/FormatTestJava.cpp
index 160c22022d2..8fadfc09b3e 100644
--- a/clang/unittests/Format/FormatTestJava.cpp
+++ b/clang/unittests/Format/FormatTestJava.cpp
@@ -426,6 +426,7 @@ TEST_F(FormatTestJava, CppKeywords) {
verifyFormat("public void union(Type a, Type b);");
verifyFormat("public void struct(Object o);");
verifyFormat("public void delete(Object o);");
+ verifyFormat("return operator && (aa);");
}
TEST_F(FormatTestJava, NeverAlignAfterReturn) {
OpenPOWER on IntegriCloud