<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63170>63170</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-format adds incorrect indentation and trailing whitespace after 4b9764959dc4b8783e18747c1742ab164e4bc4ee
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-format
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ilovepi
</td>
</tr>
</table>
<pre>
After https://reviews.llvm.org/D151954 we're seeing some significant regressions in the output of clang-format.
[formating_output.zip](https://github.com/llvm/llvm-project/files/11680534/formating_output.zip)
The code in this example is generated and formatted w/ clang-format and diffed against a golden file (golden.h). To be clear the golden and generated file are both formatted w/ clang-format prior to diffing to avoid needlessly detecting irrelevant changes. Our `.clang-format` file can be found here: https://cs.opensource.google/fuchsia/fuchsia/+/main:.clang-format
As can be seen in bad.h, includes are indented when they shouldn't be and there is whitespace added after lines in many cases. There are also a number of empty lines left in the file.
To illustrate I'm incuding a snippet of the first 30 lines from `golden.h` and `bad.h`:
`golden.h`
```
// WARNING: This file is machine generated by fidlgen.
// fidl_experiment = no_optional_structs
// fidl_experiment = output_index_json
// fidl_experiment = simple_empty_response_syntax
// fidl_experiment = unknown_interactions
#pragma once
#include <lib/fidl/cpp/wire/array.h>
#include <lib/fidl/cpp/wire/envelope.h>
#include <lib/fidl/cpp/wire/internal/transport_err.h>
#include <lib/fidl/cpp/wire/message.h>
#include <lib/fidl/cpp/wire/message_storage.h>
#include <lib/fidl/cpp/wire/object_view.h>
#include <lib/fidl/cpp/wire/string_view.h>
#include <lib/fidl/cpp/wire/traits.h>
#include <lib/fidl/cpp/wire/wire_types.h>
#include <lib/stdcompat/optional.h>
#include <cinttypes>
#ifdef __Fuchsia__
#include <lib/zx/channel.h>
#endif // __Fuchsia__
#include <fidl/test.anonymous/cpp/common_types.h>
#include <fidl/test.anonymous/cpp/markers.h>
#pragma clang diagnostic push
```
`bad.h`
```
// WARNING: This file is machine generated by fidlgen.
// fidl_experiment = no_optional_structs
// fidl_experiment = output_index_json
// fidl_experiment = simple_empty_response_syntax
// fidl_experiment = unknown_interactions
#pragma once
#include <lib/fidl/cpp/wire/array.h>
#include <lib/fidl/cpp/wire/envelope.h>
#include <lib/fidl/cpp/wire/internal/transport_err.h>
#include <lib/fidl/cpp/wire/message.h>
#include <lib/fidl/cpp/wire/message_storage.h>
#include <lib/fidl/cpp/wire/object_view.h>
#include <lib/fidl/cpp/wire/string_view.h>
#include <lib/fidl/cpp/wire/traits.h>
#include <lib/fidl/cpp/wire/wire_types.h>
#include <lib/stdcompat/optional.h>
#include <cinttypes>
#ifdef __Fuchsia__
#include <lib/zx/channel.h>
#endif // __Fuchsia__
#include <fidl/test.anonymous/cpp/common_types.h>
#include <fidl/test.anonymous/cpp/markers.h>
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0V81u27wSfRp6M6ggUbJsL7xwm-uLbnqBiwDfUqDIkcSWIgUOlcR9-g-UnTRO1dgxUCCIrJ9zZjhneKQRRLq1iFu2_MyWdwsxhs75rTbuAQe9qJ06bHdNQA9dCAOxfMf4nvG9xweNj5QY89AnzreM7--yZbZZFvCIjK88AiFq2wK5HiEG0Y2Wwgbw2Hok0s4SaAuhQ3BjGMYArgFphG0_Nc73IiQsvWPpji0_H8-1bavjk8lPPbDlHePr86xaHbqxTqTrGd_H1E6HT4N331EGxveNNkiM77OsXKfLvIiX5tj55hR9-n_fIUin8JiwJsAn0Q8GQRO0aNGLgAqEVXAki2ePjO_P1jPdV7pp4qOt0JYCCGidUWgh5gWMr4-nScf4JoF7BzWCNCj8VKfTs5HnV9QJKTxC7UL3bvzBa-chuCmJqE1wIB6cVmARlUEicwCFAWWsBmjv0eBD1Ex2wrZICfxv9MDKNHnNy8r0mIQUNubbuNEq6NAjy3dv-kZS4ga05EYvMWmdaw1GCUbZkRZnvxj_zPi-F9qyfHce8JUyO3oOS4g26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