<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/56258>56258</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Should clang-format remove breaks after ALL_CAPS return types
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
BradL-Msft
</td>
</tr>
</table>
<pre>
Sample Code:
```c
uint32_t SomeFunctionLongName( uint32_t param1, // aaaaaaaaaaaaaaaaasssssssssssssssssssssssssssssssssssssssss
uint32_t param2, // aaaaaaaaaaaaaaaaassssssssssssssssssssssssss
uint32_t param3 // aaaaaaaaaaaaaaaaa
);
MYTYPE SomeFunctionLongName2( MYTYPE param1, // aaaaaaaaaaaaaaaaasssssssssssssssssssssssssssssssssssssssss
MYTYPE* param2, // aaaaaaaaaaaaaaaaassssssssssssssssssssssssss
MYTYPE** param3 // aaaaaaaaaaaaaaaaa
);
uint32_t SomeFunctionLongName( uint32_t param1, // aaaaaaaaaaaaaaaaa
uint32_t param2, // aaaaaaaaaaaaaaaaa
uint32_t param3 // aaaaaaaaaaaaaaaaa
)
{
return param1 + param2 + param3; // blah
}
mytype SomeFunctionLongName2( mytype param1, // aaaaaaaaaaaaaaaaasssssssssssssssssssssssssssssssssssssssss
mytype* param2, // aaaaaaaaaaaaaaaaassssssssssssssssssssssssss
mytype** param3 // aaaaaaaaaaaaaaaaa
);
{
return param1 + param2 + param3; // sic
}
```
When run with a short line length and a forced break after return types:
```
---
Language: Cpp
BasedOnStyle: LLVM
AlwaysBreakAfterDefinitionReturnType: All
AlwaysBreakAfterReturnType: All
ColumnLimit: 20
PenaltyExcessCharacter: 10
PenaltyReturnTypeOnItsOwnLine: 100000000
...
```
lines are wrapped as expected:
```
************ FIRST REFORMAT
uint32_t
SomeFunctionLongName(
uint32_t param1, // aaaaaaaaaaaaaaaaasssssssssssssssssssssssssssssssssssssssss
uint32_t param2, // aaaaaaaaaaaaaaaaassssssssssssssssssssssssss
uint32_t param3 // aaaaaaaaaaaaaaaaa
);
MYTYPE
SomeFunctionLongName2(
MYTYPE param1, // aaaaaaaaaaaaaaaaasssssssssssssssssssssssssssssssssssssssss
MYTYPE *param2, // aaaaaaaaaaaaaaaaassssssssssssssssssssssssss
MYTYPE **param3 // aaaaaaaaaaaaaaaaa
);
uint32_t
SomeFunctionLongName(
uint32_t param1, // aaaaaaaaaaaaaaaaa
uint32_t param2, // aaaaaaaaaaaaaaaaa
uint32_t param3 // aaaaaaaaaaaaaaaaa
) {
return param1 +
param2 +
param3; // blah
}
mytype
SomeFunctionLongName2(
mytype param1, // aaaaaaaaaaaaaaaaasssssssssssssssssssssssssssssssssssssssss
mytype *param2, // aaaaaaaaaaaaaaaaassssssssssssssssssssssssss
mytype **param3 // aaaaaaaaaaaaaaaaa
);
{
return param1 +
param2 +
param3; // sic
}
```
Running clang-format again with a longer line length on this first output file with a new format that doesn't want breaks after return types and longer lines:
```
---
Language: Cpp
BasedOnStyle: LLVM
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
ColumnLimit: 120
PenaltyExcessCharacter: 10
PenaltyReturnTypeOnItsOwnLine: 100000000
...
```
results in this:
```
************ FINAL RESULT
uint32_t SomeFunctionLongName(uint32_t param1, // aaaaaaaaaaaaaaaaasssssssssssssssssssssssssssssssssssssssss
uint32_t param2, // aaaaaaaaaaaaaaaaassssssssssssssssssssssssss
uint32_t param3 // aaaaaaaaaaaaaaaaa
);
MYTYPE
SomeFunctionLongName2(MYTYPE param1, // aaaaaaaaaaaaaaaaasssssssssssssssssssssssssssssssssssssssss
MYTYPE *param2, // aaaaaaaaaaaaaaaaassssssssssssssssssssssssss
MYTYPE **param3 // aaaaaaaaaaaaaaaaa
);
uint32_t SomeFunctionLongName(uint32_t param1, // aaaaaaaaaaaaaaaaa
uint32_t param2, // aaaaaaaaaaaaaaaaa
uint32_t param3 // aaaaaaaaaaaaaaaaa
) {
return param1 + param2 + param3; // blah
}
mytype SomeFunctionLongName2(mytype param1, // aaaaaaaaaaaaaaaaasssssssssssssssssssssssssssssssssssssssss
mytype *param2, // aaaaaaaaaaaaaaaaassssssssssssssssssssssssss
mytype **param3 // aaaaaaaaaaaaaaaaa
);
{
return param1 + param2 + param3; // sic
}
```
Observe that the function names were re-merged with the return types in cases where the return type was lower case, but NOT in the case where the return type is ALL CAPS.
The function definition for `LongName2` is intentionally in mismatched case to the declaration to test the case-sensitive issue. If the definition uses `MYTYPE` then it also has the return type on a separate line:
```
MYTYPE
SomeFunctionLongName2(MYTYPE param1, // aaaaaaaaaaaaaaaaasssssssssssssssssssssssssssssssssssssssss
mytype *param2, // aaaaaaaaaaaaaaaaassssssssssssssssssssssssss
mytype **param3 // aaaaaaaaaaaaaaaaa
);
{
return param1 + param2 + param3; // sic
}
```
What's happening here? Am I doing something wrong?
Thanks!
P.S.
```
c:\dev\clangerror>clang-format --version
clang-format version 12.0.0
(the version that shipped with VS 2019)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzNWF1v4joQ_TXhxSJKkwXKAw9Ai1SJlqqwu9qnlZMMJHcdJ7Kdsvz7O3YCCV-9LQ1710Jp4rHP2DPjOeP6abgZzGmSMSDjNATLG1rOneUMra5T_ILy2zzzmCvP_anIPE1gkvNAxSmfpnz1RBOw3FuyG5BRQZMbyx0Ty53gj9DDJt_bDlQbZPcy5FNQ3lmccudu3_JGdSs8_lj8eL4_aQNXG6GUN26CAtdyhw3YYIe1g_u4HZqMhg87-VJXFi-9ciMEmwCVC16uERFGpfbq1cONb6F9RqMtyF3dGslGbTI4HxWlvPGoKHCbiYod1mVRcblVZRwcGnWbgIrP7xFwInJO1rGKCCUySoUiLOZAGPCV7uMh9i9TEUBIfAH0F6FLBWK7Er0zeZzfis92u128TClf5XSlEyEp2zjLCtmISghnfK42zMin02-PhWTI1nQjR1rpUOu8g2XMYx0CL0b5QlsVZwwZOz3hzLBxyvK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