summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorPaul Hoad <mydeveloperday@gmail.com>2019-03-23 14:43:41 +0000
committerPaul Hoad <mydeveloperday@gmail.com>2019-03-23 14:43:41 +0000
commitf5e52738fe9d991e065233b5b239ba491d76fe3b (patch)
treedf65b292f042eb0631321cbdfddd282318f9d879 /clang
parentc6deae452197631a4530a50df266cdf5063b601e (diff)
downloadbcm5719-llvm-f5e52738fe9d991e065233b5b239ba491d76fe3b.tar.gz
bcm5719-llvm-f5e52738fe9d991e065233b5b239ba491d76fe3b.zip
[clang-format] Keep protobuf "package" statement on one line
Summary: Top-level "package" and "import" statements should generally be kept on one line, for all languages. Reviewers: sammccall, krasimir, MyDeveloperDay Reviewed By: MyDeveloperDay Subscribers: MyDeveloperDay, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59627 Patch By: dchai (Donald Chai) llvm-svn: 356835
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp6
-rw-r--r--clang/unittests/Format/FormatTestProto.cpp6
2 files changed, 9 insertions, 3 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index ccf5e51576d..a3000a8fdeb 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1119,10 +1119,10 @@ public:
return LT_ImportStatement;
}
- // In .proto files, top-level options are very similar to import statements
- // and should not be line-wrapped.
+ // In .proto files, top-level options and package statements are very
+ // similar to import statements and should not be line-wrapped.
if (Style.Language == FormatStyle::LK_Proto && Line.Level == 0 &&
- CurrentToken->is(Keywords.kw_option)) {
+ CurrentToken->isOneOf(Keywords.kw_option, Keywords.kw_package)) {
next();
if (CurrentToken && CurrentToken->is(tok::identifier))
return LT_ImportStatement;
diff --git a/clang/unittests/Format/FormatTestProto.cpp b/clang/unittests/Format/FormatTestProto.cpp
index d5683b5b844..fd4870c27f2 100644
--- a/clang/unittests/Format/FormatTestProto.cpp
+++ b/clang/unittests/Format/FormatTestProto.cpp
@@ -393,6 +393,12 @@ TEST_F(FormatTestProto, FormatsOptions) {
"};");
}
+TEST_F(FormatTestProto, DoesntWrapPackageStatements) {
+ verifyFormat(
+ "package"
+ " some.really.long.package.that.exceeds.the.column.limit00000000;");
+}
+
TEST_F(FormatTestProto, FormatsService) {
verifyFormat("service SearchService {\n"
" rpc Search(SearchRequest) returns (SearchResponse) {\n"
OpenPOWER on IntegriCloud