[PATCH] D79414: [clang-format] C# always regards && as a binary operator

2020-05-05 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG047898c9aa1d: [clang-format] C# always regards  as 
a binary operator (authored by Jonathan Coe jb...@google.com).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79414/new/

https://reviews.llvm.org/D79414

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTestCSharp.cpp


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -706,6 +706,9 @@
   verifyFormat(R"(char[,,] rawCharArray = MakeCharacterGrid();)", Style);
   verifyFormat(R"(var (key, value))", Style);
 
+  // `&&` is not seen as a reference.
+  verifyFormat(R"(A == typeof(X) && someBool)", Style);
+
   // Not seen as a C-style cast.
   verifyFormat(R"(//
 foreach ((A a, B b) in someList) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1852,6 +1852,10 @@
 if (Style.Language == FormatStyle::LK_JavaScript)
   return TT_BinaryOperator;
 
+// && in C# must be a binary operator.
+if (Style.isCSharp() && Tok.is(tok::ampamp))
+  return TT_BinaryOperator;
+
 const FormatToken *PrevToken = Tok.getPreviousNonComment();
 if (!PrevToken)
   return TT_UnaryOperator;


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -706,6 +706,9 @@
   verifyFormat(R"(char[,,] rawCharArray = MakeCharacterGrid();)", Style);
   verifyFormat(R"(var (key, value))", Style);
 
+  // `&&` is not seen as a reference.
+  verifyFormat(R"(A == typeof(X) && someBool)", Style);
+
   // Not seen as a C-style cast.
   verifyFormat(R"(//
 foreach ((A a, B b) in someList) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1852,6 +1852,10 @@
 if (Style.Language == FormatStyle::LK_JavaScript)
   return TT_BinaryOperator;
 
+// && in C# must be a binary operator.
+if (Style.isCSharp() && Tok.is(tok::ampamp))
+  return TT_BinaryOperator;
+
 const FormatToken *PrevToken = Tok.getPreviousNonComment();
 if (!PrevToken)
   return TT_UnaryOperator;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79414: [clang-format] C# always regards && as a binary operator

2020-05-05 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

LGTM, thank you


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79414/new/

https://reviews.llvm.org/D79414



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79414: [clang-format] C# always regards && as a binary operator

2020-05-05 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe created this revision.
jbcoe added reviewers: krasimir, MyDeveloperDay.
jbcoe added a project: clang-format.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

LGTM, thank you


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79414

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTestCSharp.cpp


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -706,6 +706,9 @@
   verifyFormat(R"(char[,,] rawCharArray = MakeCharacterGrid();)", Style);
   verifyFormat(R"(var (key, value))", Style);
 
+  // `&&` is not seen as a reference.
+  verifyFormat(R"(A == typeof(X) && someBool)", Style);
+
   // Not seen as a C-style cast.
   verifyFormat(R"(//
 foreach ((A a, B b) in someList) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1852,6 +1852,10 @@
 if (Style.Language == FormatStyle::LK_JavaScript)
   return TT_BinaryOperator;
 
+// && in C# must be a binary operator.
+if (Style.isCSharp() && Tok.is(tok::ampamp))
+  return TT_BinaryOperator;
+
 const FormatToken *PrevToken = Tok.getPreviousNonComment();
 if (!PrevToken)
   return TT_UnaryOperator;


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -706,6 +706,9 @@
   verifyFormat(R"(char[,,] rawCharArray = MakeCharacterGrid();)", Style);
   verifyFormat(R"(var (key, value))", Style);
 
+  // `&&` is not seen as a reference.
+  verifyFormat(R"(A == typeof(X) && someBool)", Style);
+
   // Not seen as a C-style cast.
   verifyFormat(R"(//
 foreach ((A a, B b) in someList) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1852,6 +1852,10 @@
 if (Style.Language == FormatStyle::LK_JavaScript)
   return TT_BinaryOperator;
 
+// && in C# must be a binary operator.
+if (Style.isCSharp() && Tok.is(tok::ampamp))
+  return TT_BinaryOperator;
+
 const FormatToken *PrevToken = Tok.getPreviousNonComment();
 if (!PrevToken)
   return TT_UnaryOperator;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits