<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - clang-format indents protobuf incorrectly when an option has a composite value"
href="https://bugs.llvm.org/show_bug.cgi?id=40360">40360</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang-format indents protobuf incorrectly when an option has a composite value
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>8.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Formatter
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>jhump@bluegosling.com
</td>
</tr>
<tr>
<th>CC</th>
<td>djasper@google.com, klimek@google.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>I'm using clang-format on OS X to format protocol buffer sources.
--------------------------
$ clang-format --version
clang-format version 8.0.0 (tags/google/stable/2018-12-18)
--------------------------
I have a few proto source files that get improperly formatted. The indentation
is wrong: the formatter un-indents one too many after composite option value
ends.
Example protobuf code (test.proto):
--------------------------
syntax = "proto3";
package fullstory.users.v1;
import "google/api/annotations.proto";
import "google/protobuf/empty.proto";
import "protoc-gen-swagger/options/annotations.proto";
option go_package = "users";
service Foo {
rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty) {
option (google.api.http).get = "/foo/bar";
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) =
{
summary: "Query for foobar",
description: "Query for a bar using a foo";
};
}
rpc Baz(google.protobuf.Empty) returns (google.protobuf.Empty) {
option (google.api.http).delete = "/foo/baz";
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) =
{
summary: "Initiates a baz process",
description: "Start processing a given baz";
};
}
}
--------------------------
The above is actually what I would expect the output of the formatter to be. So
if I run it through clang-format, I would expect no change. Instead, the last
several lines of the service get incorrectly un-indented.
--------------------------
$ clang-format '-style={BasedOnStyle: google, ColumnLimit: 150, IndentWidth: 4,
SpacesBeforeTrailingComments: 1, PenaltyBreakComment: 10}' < test.proto
syntax = "proto3";
package fullstory.users.v1;
import "google/api/annotations.proto";
import "google/protobuf/empty.proto";
import "protoc-gen-swagger/options/annotations.proto";
option go_package = "users";
service Foo {
rpc Bar(google.protobuf.Empty) returns(google.protobuf.Empty) {
option(google.api.http).get = "/foo/bar";
option(grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
summary : "Query for foobar",
description : "Query for a bar using a foo";
};
}
rpc Baz(google.protobuf.Empty) returns(google.protobuf.Empty) {
option(google.api.http).delete = "/foo/baz";
option(grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
summary : "Initiates a baz process",
description : "Start processing a given baz";
};
}
}
--------------------------</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>