diff options
author | Daniel Jasper <djasper@google.com> | 2013-08-30 10:36:58 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-08-30 10:36:58 +0000 |
commit | 8ddfa8489bf6e33138fbae5cc5b9a19abe1fda8d (patch) | |
tree | b93899886522f00b3e36ae680fa795600e806c9a /clang/lib | |
parent | b71508727859e1aef49c8f08e85cb3865a51a417 (diff) | |
download | bcm5719-llvm-8ddfa8489bf6e33138fbae5cc5b9a19abe1fda8d.tar.gz bcm5719-llvm-8ddfa8489bf6e33138fbae5cc5b9a19abe1fda8d.zip |
clang-format: Enable formatting of protocol buffer definitions.
Almost by accident, clang-format seems to be able to format protocol
buffer definitions (https://code.google.com/p/protobuf/).
The only change is that a space is required between numeric constants
and opening square brackets (for default values). While this might in
theory be used for array subscripts (int val = 4[MyArray]), I have not
seen this pattern in practice much. If this is wrong, we can make this
smarter in the future.
llvm-svn: 189663
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index ce837d42ccc..d2cb5a8723b 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1206,7 +1206,8 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, return Left.Type == TT_ObjCArrayLiteral && Right.isNot(tok::r_square); if (Right.is(tok::r_square)) return Right.Type == TT_ObjCArrayLiteral; - if (Right.is(tok::l_square) && Right.Type != TT_ObjCMethodExpr) + if (Right.is(tok::l_square) && Right.Type != TT_ObjCMethodExpr && + Left.isNot(tok::numeric_constant)) return false; if (Left.is(tok::colon)) return Left.Type != TT_ObjCMethodExpr; |