summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-11-14 13:03:40 +0000
committerDaniel Jasper <djasper@google.com>2014-11-14 13:03:40 +0000
commit6c22c44e12ac0082aabb467607c77cd09a4f025c (patch)
treec1e82f80021e559408fa53e867e49b1188725ec8 /clang/unittests/Format/FormatTest.cpp
parentba7308c07e6d57b020eeb6915220fdc9636edd46 (diff)
downloadbcm5719-llvm-6c22c44e12ac0082aabb467607c77cd09a4f025c.tar.gz
bcm5719-llvm-6c22c44e12ac0082aabb467607c77cd09a4f025c.zip
clang-format: Support assignments as conditional operands.
Before: return a != b // comment ? a : a = a != b // comment ? a = b : a; After: return a != b // comment ? a : a = a != b // comment ? a = b : a; llvm-svn: 221987
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r--clang/unittests/Format/FormatTest.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index d2e577aacbd..0510871a053 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -4132,6 +4132,26 @@ TEST_F(FormatTest, BreaksConditionalExpressions) {
" ccccccccccccccccccccccccccccccccccccccc\n"
" ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
" : bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb);");
+
+ // Assignments in conditional expressions. Apparently not uncommon :-(.
+ verifyFormat("return a != b\n"
+ " // comment\n"
+ " ? a = b\n"
+ " : a = b;");
+ verifyFormat("return a != b\n"
+ " // comment\n"
+ " ? a = a != b\n"
+ " // comment\n"
+ " ? a = b\n"
+ " : a\n"
+ " : a;\n");
+ verifyFormat("return a != b\n"
+ " // comment\n"
+ " ? a\n"
+ " : a = a != b\n"
+ " // comment\n"
+ " ? a = b\n"
+ " : a;");
}
TEST_F(FormatTest, BreaksConditionalExpressionsAfterOperator) {
OpenPOWER on IntegriCloud