我在代码中使用了deprecated attribute,但我还没有找到clang-format文档记录的在C属性后中断的方法。我希望do_not_use()
函数的定义从[[deprecated]]
属性后的下一行开始。
有没有办法在C属性之后中断?
当前状态:
[[deprecated("Will be removed in version 2.3.0 as it doesn't support "
"multi-threading processing. "
"Use mt_process_info() instead")]] void
do_not_use()
{
std::cout << "This function should not be used" << std::endl;
}
所需状态:
[[deprecated("Will be removed in version 2.3.0 as it doesn't support "
"multi-threading processing. "
"Use mt_process_info() instead")]]
void do_not_use()
{
std::cout << "This function should not be used" << std::endl;
}
. clang格式:
Language: Cpp
Standard: c++20
AccessModifierOffset: 0
AlignEscapedNewlines: Right
AlignOperands: true
AllowShortFunctionsOnASingleLine: None
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: true
ColumnLimit: 100
Cpp11BracedListStyle: true
IncludeBlocks: Regroup
IndentAccessModifiers: true
IndentCaseLabels: true
IndentWidth: 4
PointerAlignment: Left
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
UseTab: Never
我试过摆弄AttributeMacros
和StatementAttributeLikeMacros
clang-format
设置,但我还没有找到解决方案。
1条答案
按热度按时间b4lqfgs41#
好消息是,最近的clang-format commit(https://github.com/llvm/llvm-project/commit/a28f0747c2f3728bd8a6f64f7c8ba80b4e0cda9f)添加了一个新的格式选项:
BreakAfterAttributes
.使用
BreakAfterAttributes: Always
可以得到所需的输出:由于这个选项是如此之新,它还没有出现在任何 * released * 版本中,但它肯定会出现在版本16中,或者您可以从源代码构建clang-format。