.clang-format 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. # SPDX-License-Identifier: Apache-2.0
  2. #
  3. # Note: The list of ForEachMacros can be obtained using:
  4. #
  5. # git grep -h '^#define [^[:space:]]*FOR_EACH[^[:space:]]*(' include/ \
  6. # | sed "s,^#define \([^[:space:]]*FOR_EACH[^[:space:]]*\)(.*$, - '\1'," \
  7. # | sort | uniq
  8. #
  9. # References:
  10. # - https://clang.llvm.org/docs/ClangFormatStyleOptions.html
  11. ---
  12. # 基于 LLVM 的代码风格
  13. BasedOnStyle: LLVM
  14. # 连续宏定义的对齐方式:跨注释对齐
  15. AlignConsecutiveMacros:
  16. Enabled: true
  17. AcrossComments: true
  18. # 短代码块不允许单行显示
  19. AllowShortBlocksOnASingleLine: Never
  20. # 短 case 标签不允许单行显示
  21. AllowShortCaseLabelsOnASingleLine: true
  22. # 短枚举不允许单行显示
  23. AllowShortEnumsOnASingleLine: false
  24. # 短函数不允许单行显示(None 表示对所有函数都应用此规则)
  25. AllowShortFunctionsOnASingleLine: None
  26. # 短 if 语句不允许单行显示
  27. AllowShortIfStatementsOnASingleLine: true
  28. # 短循环不允许单行显示
  29. AllowShortLoopsOnASingleLine: true
  30. # 属性宏列表
  31. AttributeMacros:
  32. - __aligned
  33. - __deprecated
  34. - __packed
  35. - __printf_like
  36. - __syscall
  37. - __syscall_always_inline
  38. - __subsystem
  39. # 位字段冒号后的空格位置:冒号后
  40. BitFieldColonSpacing: After
  41. BreakBeforeBraces: Custom
  42. BraceWrapping:
  43. AfterCaseLabel: false
  44. AfterClass: true
  45. AfterControlStatement: Always
  46. AfterEnum: true
  47. AfterExternBlock: false
  48. AfterFunction: true
  49. AfterNamespace: true
  50. AfterObjCDeclaration: true
  51. AfterStruct: true
  52. AfterUnion: false
  53. BeforeCatch: true
  54. BeforeElse: true
  55. BeforeLambdaBody: false
  56. BeforeWhile: false
  57. IndentBraces: false
  58. SplitEmptyFunction: true
  59. SplitEmptyRecord: true
  60. SplitEmptyNamespace: true
  61. # 单行代码的最大列数
  62. ColumnLimit: 120
  63. # 构造函数初始化列表的缩进宽度
  64. ConstructorInitializerIndentWidth: 8
  65. # 折行缩进宽度
  66. ContinuationIndentWidth: 8
  67. # ForEach 宏列表
  68. ForEachMacros:
  69. - "ARRAY_FOR_EACH"
  70. - "ARRAY_FOR_EACH_PTR"
  71. - "FOR_EACH"
  72. # If 宏列表
  73. IfMacros:
  74. - "CHECKIF"
  75. # 包含文件的分类和优先级
  76. IncludeCategories:
  77. - Regex: '^".*\.h"$'
  78. Priority: 0
  79. - Regex: '^<(assert|complex|ctype|errno|fenv|float|inttypes|limits|locale|math|setjmp|signal|stdarg|stdbool|stddef|stdint|stdio|stdlib|string|tgmath|time|wchar|wctype)\.h>$'
  80. Priority: 1
  81. - Regex: '^\<Ryan/.*\.h\>$'
  82. Priority: 2
  83. - Regex: ".*"
  84. Priority: 3
  85. # case 标签不缩进
  86. IndentCaseLabels: false
  87. # goto 标签不缩进
  88. IndentGotoLabels: false
  89. # 缩进宽度
  90. IndentWidth: 8
  91. # 自动插入大括号
  92. InsertBraces: true
  93. # 文件末尾自动插入新行
  94. InsertNewlineAtEOF: true
  95. # 继承冒号前不加空格
  96. SpaceBeforeInheritanceColon: False
  97. # 控制语句(除了控制宏)前加空格
  98. SpaceBeforeParens: ControlStatementsExceptControlMacros
  99. # 从不排序包含文件
  100. SortIncludes: Never
  101. # 使用制表符进行续行和缩进
  102. UseTab: ForContinuationAndIndentation
  103. # 对空白字符敏感的宏列表
  104. WhitespaceSensitiveMacros:
  105. - COND_CODE_0
  106. - COND_CODE_1
  107. - IF_DISABLED
  108. - IF_ENABLED
  109. - LISTIFY
  110. - STRINGIFY
  111. - Z_STRINGIFY
  112. - DT_FOREACH_PROP_ELEM_SEP