.clang-format 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. ---
  2. # 语言: None, Cpp, Java, JavaScript, ObjC, Proto, TableGen, TextProto
  3. Language: Cpp
  4. # BasedOnStyle: LLVM
  5. # 访问说明符(public、private等)的偏移
  6. AccessModifierOffset: -4
  7. # 开括号(开圆括号、开尖括号、开方括号)后的对齐: Align, DontAlign, AlwaysBreak(总是在开括号后换行)
  8. AlignAfterOpenBracket: Align
  9. # 对齐数组列
  10. AlignArrayOfStructures: None
  11. # 对齐连续宏定义
  12. AlignConsecutiveMacros: true #AcrossEmptyLinesAndComments
  13. # 连续赋值时,对齐所有等号
  14. AlignConsecutiveAssignments: true
  15. # 对齐连续位字段
  16. AlignConsecutiveBitFields: true
  17. # 连续声明时,对齐所有声明的变量名
  18. AlignConsecutiveDeclarations: true
  19. # 左对齐逃脱换行(使用反斜杠换行)的反斜杠
  20. AlignEscapedNewlines: Right
  21. # 水平对齐二元和三元表达式的操作数
  22. AllowAllArgumentsOnNextLine: true
  23. AllowAllConstructorInitializersOnNextLine: true
  24. AlwaysBreakAfterDefinitionReturnType: None
  25. AlignOperands: true #Align
  26. # 对齐连续的尾随的注释
  27. AlignTrailingComments: true
  28. # 允许函数声明的所有参数在放在下一行
  29. AllowAllParametersOfDeclarationOnNextLine: true
  30. # 允许短的枚举放在同一行
  31. AllowShortEnumsOnASingleLine: true
  32. # 允许短的块放在同一行
  33. AllowShortBlocksOnASingleLine: Never
  34. # 允许短的case标签放在同一行
  35. AllowShortCaseLabelsOnASingleLine: false
  36. # 允许短的函数放在同一行
  37. AllowShortFunctionsOnASingleLine: false #All
  38. # 允许短的匿名函数放在同一行
  39. AllowShortLambdasOnASingleLine: All
  40. # 允许短的if语句保持在同一行
  41. AllowShortIfStatementsOnASingleLine: Never
  42. # 允许短的循环保持在同一行
  43. AllowShortLoopsOnASingleLine: false
  44. # 总是在返回类型后换行
  45. AlwaysBreakAfterReturnType: None
  46. # 总是在多行string字面量前换行
  47. AlwaysBreakBeforeMultilineStrings: false
  48. # 总是在template声明后换行
  49. AlwaysBreakTemplateDeclarations: MultiLine
  50. AttributeMacros:
  51. - __capability
  52. # false表示函数实参要么都在同一行,要么都各自一行
  53. BinPackArguments: true
  54. # false表示所有形参要么都在同一行,要么都各自一行
  55. BinPackParameters: true
  56. # 是否允许短方法单行,只有一行的函数将不会分行,直接写在函数名后
  57. # 括号是分行,还是不分行,只有当 BreakBeforeBraces 设置为 Custom 时才有效
  58. BraceWrapping:
  59. AfterCaseLabel: true
  60. # class 定义后面
  61. AfterClass: true
  62. # 控制语句后面
  63. AfterControlStatement: true
  64. AfterEnum: true
  65. AfterFunction: true
  66. AfterNamespace: true
  67. AfterObjCDeclaration: true
  68. AfterStruct: true
  69. AfterUnion: true
  70. AfterExternBlock: false
  71. BeforeCatch: true
  72. BeforeElse: true
  73. # 缩进大括号
  74. IndentBraces: false
  75. SplitEmptyFunction: true
  76. SplitEmptyRecord: true
  77. SplitEmptyNamespace: true
  78. BreakBeforeBinaryOperators: None
  79. BreakBeforeBraces: Custom
  80. BreakBeforeInheritanceComma: false
  81. BreakInheritanceList: BeforeColon
  82. BreakBeforeTernaryOperators: true
  83. BreakConstructorInitializersBeforeComma: false
  84. BreakConstructorInitializers: BeforeColon
  85. BreakAfterJavaFieldAnnotations: false
  86. BreakStringLiterals: true
  87. ColumnLimit: 100
  88. CommentPragmas: "^ IWYU pragma:"
  89. CompactNamespaces: false
  90. ConstructorInitializerAllOnOneLineOrOnePerLine: false
  91. ConstructorInitializerIndentWidth: 4
  92. ContinuationIndentWidth: 4
  93. Cpp11BracedListStyle: true
  94. DeriveLineEnding: true
  95. DerivePointerAlignment: false
  96. DisableFormat: false
  97. ExperimentalAutoDetectBinPacking: false
  98. FixNamespaceComments: true
  99. ForEachMacros:
  100. - foreach
  101. - Q_FOREACH
  102. - BOOST_FOREACH
  103. IncludeBlocks: Preserve
  104. IncludeCategories:
  105. - Regex: '^"(llvm|llvm-c|clang|clang-c)/'
  106. Priority: 2
  107. SortPriority: 0
  108. - Regex: '^(<|"(gtest|gmock|isl|json)/)'
  109. Priority: 3
  110. SortPriority: 0
  111. - Regex: ".*"
  112. Priority: 1
  113. SortPriority: 0
  114. IncludeIsMainRegex: "(Test)?$"
  115. IncludeIsMainSourceRegex: ""
  116. IndentCaseLabels: false
  117. IndentGotoLabels: true
  118. IndentPPDirectives: None
  119. # 换行缩进字符数
  120. IndentWidth: 4
  121. IndentWrappedFunctionNames: false
  122. JavaScriptQuotes: Leave
  123. JavaScriptWrapImports: true
  124. KeepEmptyLinesAtTheStartOfBlocks: true
  125. MacroBlockBegin: ""
  126. MacroBlockEnd: ""
  127. MaxEmptyLinesToKeep: 1
  128. NamespaceIndentation: None
  129. ObjCBinPackProtocolList: Auto
  130. ObjCBlockIndentWidth: 0
  131. ObjCSpaceAfterProperty: false
  132. ObjCSpaceBeforeProtocolList: true
  133. PenaltyBreakAssignment: 2
  134. PenaltyBreakBeforeFirstCallParameter: 19
  135. PenaltyBreakComment: 300
  136. PenaltyBreakFirstLessLess: 120
  137. PenaltyBreakString: 1000
  138. PenaltyBreakTemplateDeclaration: 10
  139. PenaltyExcessCharacter: 1000000
  140. PenaltyReturnTypeOnItsOwnLine: 60
  141. PointerAlignment: Right
  142. ReflowComments: true
  143. SortIncludes: true
  144. SortUsingDeclarations: true
  145. SpaceAfterCStyleCast: false
  146. SpaceAfterLogicalNot: false
  147. SpaceAfterTemplateKeyword: true
  148. SpaceBeforeAssignmentOperators: true
  149. SpaceBeforeCpp11BracedList: false
  150. SpaceBeforeCtorInitializerColon: true
  151. SpaceBeforeInheritanceColon: true
  152. SpaceBeforeParens: ControlStatements
  153. SpaceBeforeRangeBasedForLoopColon: true
  154. SpaceInEmptyBlock: false
  155. SpaceInEmptyParentheses: false
  156. SpacesBeforeTrailingComments: 1
  157. SpacesInAngles: false
  158. SpacesInConditionalStatement: false
  159. SpacesInContainerLiterals: true
  160. SpacesInCStyleCastParentheses: false
  161. SpacesInParentheses: false
  162. SpacesInSquareBrackets: false
  163. # 不在[前添加空格
  164. SpaceBeforeSquareBrackets: false
  165. # 位域:每边都添加空格
  166. BitFieldColonSpacing: Both
  167. # 标准
  168. Standard: Latest
  169. # 在语句前面被忽略的宏定义,就好像它们是一个属性一样
  170. StatementAttributeLikeMacros:
  171. - Q_EMIT
  172. # 应该被解释为完整语句的宏定义
  173. StatementMacros:
  174. - Q_UNUSED
  175. - QT_REQUIRE_VERSION
  176. # tab宽度
  177. TabWidth: 4
  178. # 使用\n换行
  179. UseCRLF: false
  180. # 使用tab字符:ForIndentation——仅将制表符用于缩进
  181. UseTab: Never
  182. # 对空格敏感的宏定义
  183. WhitespaceSensitiveMacros:
  184. - STRINGIZE
  185. - PP_STRINGIZE
  186. - BOOST_PP_STRINGIZE
  187. - NS_SWIFT_NAME
  188. - CF_SWIFT_NAME
  189. ---