summaryrefslogtreecommitdiffstats
path: root/clang/unittests
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-08-30 10:36:58 +0000
committerDaniel Jasper <djasper@google.com>2013-08-30 10:36:58 +0000
commit8ddfa8489bf6e33138fbae5cc5b9a19abe1fda8d (patch)
treeb93899886522f00b3e36ae680fa795600e806c9a /clang/unittests
parentb71508727859e1aef49c8f08e85cb3865a51a417 (diff)
downloadbcm5719-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/unittests')
-rw-r--r--clang/unittests/Format/FormatTest.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index aef1dae6fdf..c30133a4b8a 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -6242,5 +6242,14 @@ TEST_F(FormatTest, FormatsWithWebKitStyle) {
format("if (aaaaaaaaaaaaaaa || bbbbbbbbbbbbbbb) { i++; }", Style));
}
+TEST_F(FormatTest, FormatsProtocolBufferDefinitions) {
+ // It seems that clang-format can format protocol buffer definitions
+ // (see https://code.google.com/p/protobuf/).
+ verifyFormat("message SomeMessage {\n"
+ " required int32 field1 = 1;\n"
+ " optional string field2 = 2 [default = \"2\"]\n"
+ "}");
+}
+
} // end namespace tooling
} // end namespace clang
OpenPOWER on IntegriCloud