<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/142050>142050</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-format] Bit field with constant width specifier aligment
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-format
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
EugeneZelenko
</td>
</tr>
</table>
<pre>
Bit field-related options does not work for widths declared as constants/macros.
Test file:
```
#define FIELD1_WIDTH 1
class Test
{
public:
constexpr static unsigned FIELD3_WIDTH = 2;
private:
unsigned field1_ : FIELD1_WIDTH;
unsigned field2_ : 10;
unsigned field3_ : FIELD3_WIDTH;
unsigned field4_ : 3;
};
```
I tried 19.1.1 and `main` (49d48c32e04742ebd05cbbd7dd544b1217b6d9d0)
Configuration:
```
BasedOnStyle: LLVM
BreakBeforeBraces: Allman
ColumnLimit: 100
IndentPPDirectives: AfterHash
IndentWidth: 4
LineEnding: LF
UseTab: Never
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: AcrossComments
AlignConsecutiveBitFields:
Enabled: true
AcrossEmptyLines: true
AcrossComments: true
AlignConsecutiveDeclarations:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignConsecutiveMacros: AcrossEmptyLines
AlignConsecutiveShortCaseStatements:
Enabled: true
AcrossEmptyLines: true
AcrossComments: true
AlignCaseColons: false
AlignEscapedNewlines: LeftWithLastLine
AlignOperands: Align
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseExpressionOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortCompoundRequirementOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
BitFieldColonSpacing: After
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeComma
BreakTemplateDeclarations: Yes
ConstructorInitializerIndentWidth: 0
ContinuationIndentWidth: 4
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: Always
FixNamespaceComments: true
MaxEmptyLinesToKeep: 1
PackConstructorInitializers: Never
PenaltyReturnTypeOnItsOwnLine: 1000
PointerAlignment: Left
SortUsingDeclarations: true
StatementMacros:
- PyObject_HEAD
- Q_OBJECT
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVstu6zgS_Rp6QySgKSmOF17IL1zPOLHnxncuZjYBJZZkdihSTVJx3F_fIGX5ESdBFg0EiKU6dapYjyMya0WpAEYoGaNk2mON22ozmjUlKPg_SFAvupdpvh-NhcOFAMlvDEjmgGNdO6GVxVyDxUo7vNPmBRfa4J3gbmsxh1wyAxwzi3OtrGPKWUTnFcuNtreIpIikG7CeWAKK0vYNuiOHP5IiGnEohAI8X8yW0_7z78V08wP3W2QumbXYM_jnwRiRtG4yKfKWC2PcxoW32mDrmBM5blQ4MW8JowMhiqaYomjc8tZGvDIHJ5ajU6hA_xmjKL3IqHW9htIW2iefAaIzruhrrriFRoc0B9PDj_NykXSBnRHAcX9427_tY6Y4RnekYkKhO4IRvY-HPL7PIwokHsQUMk6SPMv4gPMkjrM-7Q-yOz7kBNFhyzjRqhBlY5hv94ddGjMLfKWe3D60ES-X_31oUWMD7GUMhTYwNiwH682plBVTgVk2lVqKSri2Sp5soTgot15PhYHcideDT-HA_GB2e0T89kPmTTEi6VIomCkuVBnizxFJf1nYsMw_PsIrmDafJVNlw8qQ5aSuEUnTPAdrHzQXhQCzKgoLIZkbT5tKUaoQelWD8id4aa2p3LG9DafrYBOtLOSNzzgNW1WBH3cP9uNuJ7pq31zjx8LNfYdtN3EzxTIJ3Ds704B_15LMqtrt_WHtue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