<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/76253>76253</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-format uses resets formatting when BraceWrappingAfterControlStatementStyle is set to anything.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-format
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
rickymcmuffin
</td>
</tr>
</table>
<pre>
When setting BraceWrappingAfterControlStatementStyle to any option it changes the indent width to 2.
Here is my configuration:
```
# We'll use defaults from the LLVM style, but with 4 columns indentation.
BasedOnStyle: LLVM
IndentWidth: 4
---
Language: Cpp
BreakBeforeBraces: Custom
# BraceWrappingAfterControlStatementStyle: BWACS_Always
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
# AfterControlStatement: BWACS_Never
AfterEnum: true
AfterFunction: true
AfterNamespace: true
# AfterObjDecleration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
```
And here is a snippet of my code with this:
```
int main()
{
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
GLFWwindow *window = glfwCreateWindow(800, 600, "GameTime", NULL, NULL);
if (window == NULL) {
std::cout << "Failed to create GLFW window" << std::endl;
glfwTerminate();
return -1;
}
```
However, if I change the configuration to this:
```
# We'll use defaults from the LLVM style, but with 4 columns indentation.
BasedOnStyle: LLVM
IndentWidth: 4
---
Language: Cpp
BreakBeforeBraces: Custom
# BraceWrappingAfterControlStatementStyle: BWACS_Always
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: BWACS_Never
AfterEnum: true
AfterFunction: true
AfterNamespace: true
# AfterObjDecleration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
```
My code looks like this:
```
int main() {
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
GLFWwindow *window = glfwCreateWindow(800, 600, "GameTime", NULL, NULL);
if (window == NULL) {
std::cout << "Failed to create GLFW window" << std::endl;
glfwTerminate();
return -1;
}
```
This happens any time it is set. Here is a list of things that I have found to cause this:
- If BraceWrappingAfterControlStatementStyle is set to anything.
- If AfterControlStatement is set to anything inside the BraceWrapping block
- If BreakBeforeBraces is set to anything but Custom
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsV11v4jgU_TXm5QqUOnw-8MDnlBWFUdsZ9q0yyU3iqWNHtlOWf7-yE8rH0orR7r61qhLIveeeY_ty7DBjeCoRh6QzJp1pg5U2U3qoefS6z6O8TBIuG1sV74ebDCUYtJbLFMaaRbjRrCi4TEeJRT1R0molniyzmKO0T3YvEKwCJvegCsuVBG4hyphM0YDNELiMUVrY8dhmLpO2SDAlwai63qNG4AbyPURKJjwtNXNVSDiCOq8b1P_VVxrCBgntCQGlQYgxYaWwBhKtck-4XP58AOOEETqBbem4bQZtiJQoc2lqRZ6m1jJmBuO19KNxzK5EFVn43I0T7wLt6mmz2aw-LJlMS5Z60KQo6moa2esYE6XRz6Dx0dJYlR_HcOPcOuh4M5o8vYzEju3NgeEETMJ6LqEqwwwu2RaFg1pdYh2so4IZcxlxeq5KOLKv8A31WaWZLPOrFPNSRoclPAn62IrlaAoW4YcS1ttfU4wEHtvgHwRPVpeRvRr6IT8Czf6yqOVYqOj1PH7ZX_46kjFkdWsyMJIXBVpQSdWnMVYtZTNu3mf_og6XFnLGJaF9Qgd1Sm98SgKpSHYLyW2dE44PisGHNlzGanfPpUv4tpxvXibr1fPsz-eXn7PHp8V69fIw-mP96Lo8PMPfCF6sbgevv89W35Yv3x_X88Vy5lCnjyfrx9kxdixWl3SpO18SCB0dP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