summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format
diff options
context:
space:
mode:
authorKrasimir Georgiev <krasimir@google.com>2019-03-11 16:02:52 +0000
committerKrasimir Georgiev <krasimir@google.com>2019-03-11 16:02:52 +0000
commitc416c52b07f5c14c4548c904bd1426c1208949bc (patch)
tree1a7c8feeabe583a74e47602326bb12ee5ac1ffc5 /clang/unittests/Format
parent3aa36c9a47f0339e9880049bb40c8c6ca0d63d00 (diff)
downloadbcm5719-llvm-c416c52b07f5c14c4548c904bd1426c1208949bc.tar.gz
bcm5719-llvm-c416c52b07f5c14c4548c904bd1426c1208949bc.zip
clang-format: distinguish ObjC call subexpressions after r355434
Summary: The revision r355434 had the unfortunate side-effect that it started to recognize certain ObjC expressions with a call subexpression followed by a `a->b` subexpression as C++ lambda expressions. This patch adds a bit of logic to handle these cases and documents them in tests. The commented-out test cases in the new test suite are ones that were problematic before r355434. Reviewers: MyDeveloperDay, gribozavr Reviewed By: MyDeveloperDay, gribozavr Subscribers: MyDeveloperDay, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59210 llvm-svn: 355831
Diffstat (limited to 'clang/unittests/Format')
-rw-r--r--clang/unittests/Format/FormatTestObjC.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTestObjC.cpp b/clang/unittests/Format/FormatTestObjC.cpp
index ef725a81a88..e1a95dbb395 100644
--- a/clang/unittests/Format/FormatTestObjC.cpp
+++ b/clang/unittests/Format/FormatTestObjC.cpp
@@ -1329,6 +1329,34 @@ TEST_F(FormatTestObjC, AlwaysBreakBeforeMultilineStrings) {
" @\"fffff\"];");
}
+TEST_F(FormatTestObjC, DisambiguatesCallsFromCppLambdas) {
+ verifyFormat("x = ([a foo:bar] && b->c == 'd');");
+ verifyFormat("x = ([a foo:bar] + b->c == 'd');");
+ verifyFormat("x = ([a foo:bar] + !b->c == 'd');");
+ verifyFormat("x = ([a foo:bar] + ~b->c == 'd');");
+ verifyFormat("x = ([a foo:bar] - b->c == 'd');");
+ verifyFormat("x = ([a foo:bar] / b->c == 'd');");
+ verifyFormat("x = ([a foo:bar] % b->c == 'd');");
+ verifyFormat("x = ([a foo:bar] | b->c == 'd');");
+ verifyFormat("x = ([a foo:bar] || b->c == 'd');");
+ verifyFormat("x = ([a foo:bar] && b->c == 'd');");
+ verifyFormat("x = ([a foo:bar] == b->c == 'd');");
+ verifyFormat("x = ([a foo:bar] != b->c == 'd');");
+ verifyFormat("x = ([a foo:bar] <= b->c == 'd');");
+ verifyFormat("x = ([a foo:bar] >= b->c == 'd');");
+ verifyFormat("x = ([a foo:bar] << b->c == 'd');");
+ verifyFormat("x = ([a foo:bar] ? b->c == 'd' : 'e');");
+ // FIXME: The following are wrongly classified as C++ lambda expressions.
+ // For example this code:
+ // x = ([a foo:bar] & b->c == 'd');
+ // is formatted as:
+ // x = ([a foo:bar] & b -> c == 'd');
+ // verifyFormat("x = ([a foo:bar] & b->c == 'd');");
+ // verifyFormat("x = ([a foo:bar] > b->c == 'd');");
+ // verifyFormat("x = ([a foo:bar] < b->c == 'd');");
+ // verifyFormat("x = ([a foo:bar] >> b->c == 'd');");
+}
+
} // end namespace
} // end namespace format
} // end namespace clang
OpenPOWER on IntegriCloud