Skip to content

clang-format mismatches braces with nested unnamed scopes #47649

@mateuszzz88

Description

@mateuszzz88
Bugzilla Link 48305
Version 11.0
OS Linux
CC @CaseyCarter,@cpplearner,@mateuszzz88

Extended Description

Hello.
With clang-format -10 and -11 installed from repo on ubuntu 20.11 following c++ code is obviously formatted wrong:

clang-format-11 -style=llvm test.cpp 
void foo() {
  {// asdf
   {int a;
}
}
{
  { int b; }
}
}

Removing {// asdf is sufficient to format it ok.
I expect it to be formatted like this (possibly with comment in new line, but this may be llvm style):

void foo() {
  {// asdf
    { int a; }
  }
  {
    { int b; }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions