<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/55569>55569</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-tidy with --export-fixes doesn't apply formatting with readability-braces-around-statements (but it works with --fix)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
sean-mcmanus
</td>
</tr>
</table>
<pre>
I'm using clang 14.0.0 or 14.0.3 (I assume it doesn't matter).
Use test.cpp
```cpp
int main()
{
if (true)
return 0;
}
```
with some .clang-format file in the folder like
```yaml
BasedOnStyle: LLVM
UseTab: Never
IndentWidth: 4
TabWidth: 4
BreakBeforeBraces: Allman
AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: false
ColumnLimit: 0
AccessModifierOffset: -4
NamespaceIndentation: All
FixNamespaceComments: false
SeparateDefinitionBlocks: Always
```
and run
```
clang-tidy.exe --config="{Checks: 'readability-braces-around-statements', FormatStyle: file}" --export-fixes=<path>/out.yaml <path>/test2.cpp --
```
Bug: The out.yaml is
```yaml
---
MainSourceFile: '<path>/test.cpp'
Diagnostics:
- DiagnosticName: readability-braces-around-statements
DiagnosticMessage:
Message: statement should be inside braces
FilePath: '<path>/test.cpp'
FileOffset: 30
Replacements:
- FilePath: '<path>/test.cpp'
Offset: 30
Length: 0
ReplacementText: ' {'
- FilePath: '<path>/test.cpp'
Offset: 49
Length: 0
ReplacementText: "\n}"
Level: Warning
BuildDirectory: '<path>'
...
which doesn't have the formatting applied -- in particular, the `}` has no indentation.
The bug doesn't repro when --export-fixes isn't used:
```
clang-tidy.exe --config="{Checks: 'readability-braces-around-statements', FormatStyle: file}" --fix <path>/test.cpp --
```
gives the expected result:
```
int main()
{
if (true)
{
return 0;
}
}
```
It's possible that all formatting doesn't work with --export-fixes...I've only noticed it with readability-braces-around-statements so far.
</pre>
<img width="1px" height="1px" alt="" src="http://email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