summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-01-20 16:47:22 +0000
committerDaniel Jasper <djasper@google.com>2014-01-20 16:47:22 +0000
commit929b1db276aa6735da81bc0bc206d0f81fe7c334 (patch)
tree3be83a1a7168f3d414e594ab8eab64e8481532ad
parent3f5f3e7949f60f96b8b35a32dd5f517cd03cc036 (diff)
downloadbcm5719-llvm-929b1db276aa6735da81bc0bc206d0f81fe7c334.tar.gz
bcm5719-llvm-929b1db276aa6735da81bc0bc206d0f81fe7c334.zip
clang-format: Properly format custom options in protocol buffer definitions.
Before: option(my_option) = "abc"; After: option (my_option) = "abc"; llvm-svn: 199672
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp3
-rw-r--r--clang/unittests/Format/FormatTestProto.cpp5
2 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index b1f414f8dd7..7b2c595403a 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1254,7 +1254,8 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
const FormatToken &Left,
const FormatToken &Right) {
if (Style.Language == FormatStyle::LK_Proto) {
- if (Right.is(tok::l_paren) && Left.TokenText == "returns")
+ if (Right.is(tok::l_paren) &&
+ (Left.TokenText == "returns" || Left.TokenText == "option"))
return true;
}
if (Right.is(tok::hashhash))
diff --git a/clang/unittests/Format/FormatTestProto.cpp b/clang/unittests/Format/FormatTestProto.cpp
index d102c6567c1..7623e46db44 100644
--- a/clang/unittests/Format/FormatTestProto.cpp
+++ b/clang/unittests/Format/FormatTestProto.cpp
@@ -68,5 +68,10 @@ TEST_F(FormatTestProto, MessageFieldAttributes) {
" [default = REALLY_REALLY_LONG_CONSTANT_VALUE];");
}
+TEST_F(FormatTestProto, FormatsOptions) {
+ verifyFormat("option java_package = \"my.test.package\";");
+ verifyFormat("option (my_custom_option) = \"abc\";");
+}
+
} // end namespace tooling
} // end namespace clang
OpenPOWER on IntegriCloud