summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format
diff options
context:
space:
mode:
authorBen Hamilton <benhamilton@google.com>2019-02-08 15:55:18 +0000
committerBen Hamilton <benhamilton@google.com>2019-02-08 15:55:18 +0000
commit30b7d09d7a3151118d6ee6dc8582a3eb87286ef4 (patch)
treeafe7d8d43e47bd23bae036a663522446123acaf0 /clang/unittests/Format
parent494b8ac95a79031fc19266dea42d29e140444b47 (diff)
downloadbcm5719-llvm-30b7d09d7a3151118d6ee6dc8582a3eb87286ef4.tar.gz
bcm5719-llvm-30b7d09d7a3151118d6ee6dc8582a3eb87286ef4.zip
[Format/ObjC] Fix [foo bar]->baz formatting as lambda arrow
Summary: Currently, `UnwrappedLineParser` thinks an arrow token after an ObjC method expression is a C++ lambda arrow, so it formats: ``` [foo bar]->baz ``` as: ``` [foo bar] -> baz ``` Because `UnwrappedLineParser` runs before `TokenAnnotator`, it can't know if the arrow token is after an ObjC method expression or not. This diff makes `TokenAnnotator` remove the TT_LambdaArrow on the arrow token if it follows an ObjC method expression. Test Plan: New test added. Ran test with: % ninja FormatTests && ./tools/clang/unittests/Format/FormatTests Confirmed test failed before diff and passed after diff. Reviewers: krasimir, djasper, sammccall Reviewed By: sammccall Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D57923 llvm-svn: 353531
Diffstat (limited to 'clang/unittests/Format')
-rw-r--r--clang/unittests/Format/FormatTestObjC.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTestObjC.cpp b/clang/unittests/Format/FormatTestObjC.cpp
index 0d3a5d85bb7..ef725a81a88 100644
--- a/clang/unittests/Format/FormatTestObjC.cpp
+++ b/clang/unittests/Format/FormatTestObjC.cpp
@@ -611,6 +611,7 @@ TEST_F(FormatTestObjC, FormatObjCMethodDeclarations) {
TEST_F(FormatTestObjC, FormatObjCMethodExpr) {
verifyFormat("[foo bar:baz];");
+ verifyFormat("[foo bar]->baz;");
verifyFormat("return [foo bar:baz];");
verifyFormat("return (a)[foo bar:baz];");
verifyFormat("f([foo bar:baz]);");
OpenPOWER on IntegriCloud