Skip to content

[clang-format] clang-format v21 ampersand spacing inconsistent in .h file with "Language C" section (regression from v20) #158704

@mydeveloperday

Description

@mydeveloperday

Changes in .h files seems to occur between clang-format v20 and v21, when .clang-format has a "C" Language section

(both indentation and spaces around &)

------------------------ test.h -------------------------
namespace Foo
{
void bar(arg1 &result);
void bar2(const arg1 &result);
}


----------------------- .clang-format ----------
Language: Cpp
BasedOnStyle: LLVM
...
Language: C
BasedOnStyle: LLVM


clang-format-20 (20.1.0)

namespace Foo {
void bar(arg1 &result);
void bar2(const arg1 &result);
} // namespace Foo


clang-format-21 (21.1.1)

namespace Foo {
void bar(arg1 & result);
void bar2(const arg1 &result);
}

.h file is obviously considered C not C++ if I remove the Language C section from .clang-format output is ad in cf-20

namespace Foo {
void bar(arg1 &result);
void bar2(const arg1 &result);
} // namespace Foo

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions