<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/140939>140939</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-format using "Macro:" to replace macros does not give expected alignment
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-format
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
dawdolman
</td>
</tr>
</table>
<pre>
When using the following .clang-format file on some C++ code that uses Macros to define const arrays of data the formatted output is not as expected:
```
---
BasedOnStyle: Microsoft
AlignArrayOfStructures: Right
AlignConsecutiveAssignments:
Enabled: true
AlignConsecutiveBitFields:
Enabled: true
AlignConsecutiveDeclarations:
Enabled: true
AlignConsecutiveMacros:
Enabled: true
AlignConsecutiveShortCaseStatements:
Enabled: true
AllowShortFunctionsOnASingleLine: Empty
BraceWrapping:
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: Always
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: false
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
NamespaceIndentation: All
PointerAlignment: Left
QualifierAlignment: Left
SpaceBeforeParens: Never
SpacesInAngles: Always
SpacesInParens: Custom
SpacesInParensOptions:
InConditionalStatements: true
Other: true
SpacesInSquareBrackets: true
FixNamespaceComments: false
Macros:
- BeginPropertyTable(a)=const int something[] = {
- PropertyEntryString(a,b,c)={ 0 }
- EndPropertyTable(a)=};
```
Input and expected results:
```
const int a[] = {
{ 0 },
{ 0 },
};
BeginPropertyTable( CLocation )
PropertyEntryString( _P( "description" ), CLocation, m_szDescription ),
PropertyEntryString( _P( "file" ), CLocation, m_szFile ),
EndPropertyTable( CLocation )
```
Actual formatting results in the following output where replaced macro elements are grouped into a single line instead of being formatted in the same way as the const int a[] expression above:
```
const int a[] = {
{ 0 },
{ 0 },
};
BeginPropertyTable( CLocation ) PropertyEntryString( _P( "description" ), CLocation, m_szDescription ),
PropertyEntryString( _P( "file" ), CLocation, m_szFile ), EndPropertyTable( CLocation )
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVl1v4joT_jXmZkSVGihwwUWgRarU3fZd3qO9XE3iSeJdx86xnVLOrz-yAwQW9nQrrVQVZb79-JkZo3Oy1EQLNlmyyf0AW18ZuxC4FUbVqAeZEbvF14o0tE7qEnxFUBilzDZ83eQKdTksjK3RQyEVgdHgTE2wYnzJ-BJyIwh8hR5aRw4-YW6NA29AUCE1QW6084DW4s6BKUCgx32WENSTANP6pvUgHWjjAR3QW0O5J8FGKUtSdpfs_5J0OByyJF2iI_GsN36niI1S-CRDUlN4lqSpkqVOQ7rnYuNtm_vWkgtWX2RZHS1WRjvKWy9fKY0Y1aS96xICPGjMVMwP3rZ0xWkp_VqSEh9wuadcoUUvjf6AVwfo79tvKmP9Ch1tPHp691TKbKPHutV5rOxZpxupS0VPUkdwH-rG7wLoFnP6arFppC73IdPCkw3JnjAjFawLVI5itk6n0LmThAex0d4adSwxWKRqizt3jPqg2_rS8VDmpeYz1uQazOlUFTXP2ffVCfaXrh1NLuV_6b358VBdZW-erF4qk_8481lSYSyt0OfVFflDCHEi7qRPWGcCl0bszsHrtF8r2RG8VzxqQdrHu3Bnmk2jpI93dRWjXv2FcmPFL5TXUDzKutxHEFOlWJK-GKk92UjDw1U-UWzF_7WoZCGvKzchYnfMF7QUWwI-0yvZg9I96jQQ0Z2x46DqnVat86a-UD03Z532GJpEyCBDddYbPQ7PviJ7IjkE3PzdoqUA-g86c1nLtyM6K1MfIx5uhSXpWf8OYUml1C_WNGT97v-hHxmfIeNzNrrvRqXUPk5YX4U-i2Mb2Oge2HQJscohHPwftLe7jbfBMEZZZYyv8i5asE-ATe_3Tg9a_CJvsBktf5q0jzrMZNTiOI3BkmvVYZyc2vaF43nBMTV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