Skip to content

Namespaces with one function declaration get formatted incorrectly #36114

Closed
@llvmbot

Description

@llvmbot
Bugzilla Link 36766
Version 6.0
OS All
Reporter LLVM Bugzilla Contributor
CC @krasimir-google

Extended Description

Let's consider this example:

$ cat test.cpp
namespace Foo1 { // contains a single function declaration

void a();

}
namespace Foo2 { // contains multiple function declarations

void a();
void b();

}
namespace Bar { // contains a single function definition

void b() {}

}
namespace Baz { // contains mixed definitions/declarations

void b() {}
void a();

}

clang-format formats incorrectly the first namespace:
$ clang-format --style=llvm ~/main6.cpp
namespace Foo1 { // contains a single function declaration

void a();
}
namespace Foo2 { // contains multiple function declarations

void a();
void b();

} // namespace Foo2
namespace Bar { // contains a single function definition

void b() {}

} // namespace Bar
namespace Baz { // contains mixed definitions/declarations

void b() {}
void a();

} // namespace Baz

clang-format removes a blank line before the closing brace and it doesn't fix the namespace comment.

Metadata

Metadata

Labels

bugzillaIssues migrated from bugzillaclang-formatquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions