Reputation: 139
I'm looking for a configuration options(s) for .clang-format that will make clang-format keep a MACRO on the same line as an if statement.
Current:
What I want:
Here is my current .clang-format: https://pastebin.com/GYH79k7u
---
Language: Cpp
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignOperands: false
AllowShortBlocksOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: true
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: false
BreakConstructorInitializers: AfterColon
ColumnLimit: 0
ConstructorInitializerAllOnOneLineOrOnePerLine: true
Cpp11BracedListStyle: false
...
Thank you!
Upvotes: 1
Views: 283
Reputation: 27155
Clang-format 12 adds AttributeMacros
, as in
AttributeMacros: ['_LIKELY', '_UNLIKELY']
The "clang-format 12.0.1
" installed by Homebrew doesn't yet support this option, but clang-format 14.0.6
(the current Homebrew release) does. The result with your .clang-format file plus the above line seems to give exactly what you wanted:
if( GWorldServer->SendAsync( Buffer ) != RSuccess ) _UNLIKELY
{
return RFail;
}
Upvotes: 1