如何设置Clang-Format样式选项,以在捕获前保持不合格



所以我当前使用下一个样式:

{ 
  BasedOnStyle: "LLVM", 
  IndentWidth: 4,   
  UseTab: false, 
  ColumnLimit: 150, 
  Standard: "Cpp11",
  BreakBeforeBraces: "Attach",  
  BreakBeforeBinaryOperators: false,    
  AlwaysBreakTemplateDeclarations: true, 
  AllowShortLoopsOnASingleLine: false,
  AllowShortIfStatementsOnASingleLine: false, 
  AllowAllParametersOfDeclarationOnNextLine: true, 
  SpacesInParentheses: true,    
  SpacesBeforeTrailingComments: 1, 
  SpaceInEmptyParentheses: false,
  SpaceAfterControlStatementKeyword: true, 
  PointerBindsToType: true, 
  MaxEmptyLinesToKeep: 1,
  IndentFunctionDeclarationAfterType: true, 
  IndentCaseLabels: true,
  ExperimentalAutoDetectBinPacking: true, 
  DerivePointerBinding: true, 
  Cpp11BracedListStyle: false, 
  ConstructorInitializerAllOnOneLineOrOnePerLine: true,
  BreakConstructorInitializersBeforeComma: true
}

并获得

try {
}
 catch ( ... ) {
}

我想获得

try {
} catch ( ... ) {
}

任何人都可以说哪种clang-format样式选项负责此类行为?

BreakBeforeBraces,据我所知,应该影响您关注的行为。Attach在您引用的"样式选项"页面上的描述中看起来像是正确的选项。我无法工作的唯一原因是BreakBeforeBraces期望BraceBreakingStyle枚举。尝试它,而无需使Attach成为字符串。

BreakBeforeBraces: Attach 

BreakBeforeBraces: BS_Attach 

对try-catch-blocks的支持仅是最近添加的。如果您更新到当前版本,则应修复。

最新更新