summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
diff options
context:
space:
mode:
authorKrasimir Georgiev <krasimir@google.com>2018-03-16 15:23:22 +0000
committerKrasimir Georgiev <krasimir@google.com>2018-03-16 15:23:22 +0000
commitabbd54ce009579da4aa532b83632cc584f0b7b19 (patch)
treefbad68c068771cc6f8b7d0416b28113e1399c732 /clang/lib/Format
parenta9f05a9d50bb49b54ff0fbccc5e65016edd5a0da (diff)
downloadbcm5719-llvm-abbd54ce009579da4aa532b83632cc584f0b7b19.tar.gz
bcm5719-llvm-abbd54ce009579da4aa532b83632cc584f0b7b19.zip
[clang-format] Disallow breaks before ']' in text proto extensions
Summary: This disallows patterns like `[ext.name\n]` in text protos. Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D44569 llvm-svn: 327716
Diffstat (limited to 'clang/lib/Format')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 3de454cc98a..edb5a6fd7aa 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2968,6 +2968,9 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
return false;
return true;
}
+ if (Right.is(tok::r_square) && Right.MatchingParen &&
+ Right.MatchingParen->is(TT_ProtoExtensionLSquare))
+ return false;
if (Right.is(TT_SelectorName) || (Right.is(tok::identifier) && Right.Next &&
Right.Next->is(TT_ObjCMethodExpr)))
return Left.isNot(tok::period); // FIXME: Properly parse ObjC calls.
OpenPOWER on IntegriCloud