llvm / llvm/llvm-project

[clang-format] Formatting breaks attributes with arguments

Open
#172,440 1 comment 0 reactions 0 assignees View on GitHub
clang-format
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

This behaviour exists up to including 21.1.6.

Formatting this piece with style llvm

``` c++
class CStruct {
public:
alignas(32) std::array, eP / Impl::eP> m_Buffs;
};
```

Results in

``` c++
class CStruct {
public:
alignas(
32) std::array, eP / Impl::eP> m_Buffs;
};
```

clang-format should try hard to not break up the attribute

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the formatting change with clang-format 21.1.6, using the provided C++ snippet and LLVM style. Trace the clang-format formatting path for alignas attributes with arguments; done means formatting no longer breaks the attribute across lines in this case, with a regression test covering the example.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.