【发布时间】:2020-09-02 10:47:35
【问题描述】:
在 clang-format 中,以下模板函数声明被包装成三行。我认为它应该只被包装成两个。是我的 .clang 格式文件中的问题还是工具中的错误?
template <class VEC3_T, class FLOAT_T>
FLOAT_T functionNamedBlahBlahhh(const VEC3_T blabla, const VEC3_T bla, FLOAT_T blah1,
FLOAT_T blah2) // foo
{
}
我使用的是 clang 格式版本 10.0.0。 我的 .clang 格式文件是:
BasedOnStyle: LLVM # (LLVM, Google, Chromium, Mozilla, WebKit)
AccessModifierOffset: -4
AlignEscapedNewlines: Left
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: true
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
BreakBeforeBraces: Custom # If this is "Custom" then use the BraceWrapping settings
BraceWrapping:
AfterClass: false
AfterStruct: false
AfterUnion: true
AfterEnum: true
AfterNamespace: false
AfterControlStatement: false
AfterFunction: true
AfterExternBlock: false
BeforeCatch: true
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakConstructorInitializers: AfterColon
ColumnLimit: 130 # Drawback: AllowShort*OnASingleLine kind of goes crazy with it. Is there a Penalty property to adjust this?
IncludeBlocks: Regroup
IndentCaseLabels: false
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: false
PointerAlignment: Left
SpaceBeforeCpp11BracedList: true
UseTab: Never
我还看到了一些其他情况,它会将长行包装成 3 行以上。还有一个:
OCLShaderEnv::OCLShaderEnv(OCLEnv* oclEnv, SVMStruct* svm, std::string prog, std::string kernelName, int width, int height,
std::string buildOptions, Camera* camera, void* otherStuff, std::array<float, 4> fillColor) :
m_device(oclEnv->getDevice()),
m_context(oclEnv->getContext()), m_cmdQ(oclEnv->getCmdQ()), m_prog(prog), m_kernelName(kernelName), m_width(width),
m_height(height), m_camera(camera), m_svmStructPtr(svm), m_oclEnv(oclEnv)
{
}
注意三行初始化器,它们很容易放在两行。
【问题讨论】:
标签: clang-format