Issue 76253
Summary clang-format uses resets formatting when BraceWrappingAfterControlStatementStyle is set to anything.
Labels clang-format
Assignees
Reporter rickymcmuffin
    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


_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to