1# Copyright (C) 2022 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14Language: Cpp 15# BasedOnStyle: LLVM 16# 访问说明符(public、private等)的偏移 17AccessModifierOffset: -4 18# 开括号(开圆括号、开尖括号、开方括号)后的对齐 19AlignAfterOpenBracket: Align 20# 连续赋值时,等号对齐 21AlignConsecutiveAssignments: false 22# 连续赋值时,变量名对齐 23AlignConsecutiveDeclarations: false 24# 左对齐逃脱换行(使用反斜杠换行)的反斜杠 25AlignEscapedNewlinesLeft: true 26# 水平对齐二元和三元表达式的操作数 27AlignOperands: true 28# 对齐连续的尾随的注释 29AlignTrailingComments: true 30# 允许函数声明的所有参数在放在下一行 31AllowAllParametersOfDeclarationOnNextLine: false 32# 允许短的块放在同一行 33AllowShortBlocksOnASingleLine: false 34# 允许短的case标签放在同一行 35AllowShortCaseLabelsOnASingleLine: false 36# 允许短的函数放在同一行: None, InlineOnly(定义在类中), Empty(空函数), Inline(定义在类中,空函数), All 37AllowShortFunctionsOnASingleLine: Empty 38# 允许短的if语句保持在同一行 39AllowShortIfStatementsOnASingleLine: false 40# 允许短的循环保持在同一行 41AllowShortLoopsOnASingleLine: false 42# 总是在定义返回类型后换行(deprecated) 43AlwaysBreakAfterDefinitionReturnType: None 44# 总是在返回类型后换行: None, All, TopLevel(顶级函数,不包括在类中的函数), 45# AllDefinitions(所有的定义,不包括声明), TopLevelDefinitions(所有的顶级函数的定义) 46AlwaysBreakAfterReturnType: None 47# 总是在多行string字面量前换行 48AlwaysBreakBeforeMultilineStrings: true 49# 总是在template声明后换行 50AlwaysBreakTemplateDeclarations: false 51# false表示函数实参要么都在同一行,要么都各自一行 52BinPackArguments: true 53# false表示所有形参要么都在同一行,要么都各自一行 54BinPackParameters: true 55# 大括号换行,只有当BreakBeforeBraces设置为Custom时才有效 56BraceWrapping: 57 AfterClass: false 58 AfterControlStatement: false 59 AfterEnum: false 60 AfterFunction: true 61 AfterNamespace: false 62 AfterObjCDeclaration: false 63 AfterStruct: false 64 AfterUnion: false 65 BeforeCatch: false 66 BeforeElse: false 67 IndentBraces: false 68# 在二元运算符前换行: None(在操作符后换行), NonAssignment(在非赋值的操作符前换行), All(在操作符前换行) 69BreakBeforeBinaryOperators: None 70# 在大括号前换行: Attach(始终将大括号附加到周围的上下文), Linux(除函数、命名空间和类定义,与Attach类似), 71# Mozilla(除枚举、函数、记录定义,与Attach类似), Stroustrup(除函数定义、catch、else,与Attach类似), 72# Allman(总是在大括号前换行), GNU(总是在大括号前换行,并对于控制语句的大括号增加额外的缩进), WebKit(在函数前换行), Custom 73# 注:这里认为语句块也属于函数 74BreakBeforeBraces: Custom 75# 在三元运算符前换行 76BreakBeforeTernaryOperators: true 77# 在构造函数的初始化列表的逗号前换行 78BreakConstructorInitializersBeforeComma: false 79# 每行字符的限制,0表示没有限制 80ColumnLimit: 120 81# 描述具有特殊意义的注释的正则表达式,它不应该被分割为多行或以其它方式改变 82CommentPragmas: "^ IWYU pragma:" 83# 构造函数的初始化列表要么都在同一行,要么都各自一行 84ConstructorInitializerAllOnOneLineOrOnePerLine: true 85# 构造函数的初始化列表的缩进宽度 86ConstructorInitializerIndentWidth: 4 87# 延续的行的缩进宽度 88ContinuationIndentWidth: 4 89# 去除C++11的列表初始化的大括号{后和}前的空格 90Cpp11BracedListStyle: true 91# 继承最常用的指针和引用的对齐方式 92DerivePointerAlignment: false 93# 关闭格式化 94DisableFormat: false 95# 自动检测函数的调用和定义是否被格式为每行一个参数(Experimental) 96ExperimentalAutoDetectBinPacking: false 97# 需要被解读为foreach循环而不是函数调用的宏 98ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] 99# 对#include进行排序,匹配了某正则表达式的#include拥有对应的优先级,匹配不到的则默认优先级为INT_MAX(优先级越小排序越靠前), 100# 可以定义负数优先级从而保证某些#include永远在最前面 101IncludeCategories: 102 - Regex: '^"(llvm|llvm-c|clang|clang-c)/' 103 Priority: 2 104 - Regex: '^(<|"(gtest|isl|json)/)' 105 Priority: 3 106 - Regex: ".*" 107 Priority: 1 108# 缩进case标签 109IndentCaseLabels: true 110# 缩进宽度 111IndentWidth: 4 112# 函数返回类型换行时,缩进函数声明或函数定义的函数名 113IndentWrappedFunctionNames: true 114# 保留在块开始处的空行 115KeepEmptyLinesAtTheStartOfBlocks: true 116# 开始一个块的宏的正则表达式 117MacroBlockBegin: "" 118# 结束一个块的宏的正则表达式 119MacroBlockEnd: "" 120# 连续空行的最大数量 121MaxEmptyLinesToKeep: 1 122# 命名空间的缩进: None, Inner(缩进嵌套的命名空间中的内容), All 123NamespaceIndentation: None 124# 使用ObjC块时缩进宽度 125ObjCBlockIndentWidth: 4 126# 在ObjC的@property后添加一个空格 127ObjCSpaceAfterProperty: false 128# 在ObjC的protocol列表前添加一个空格 129ObjCSpaceBeforeProtocolList: true 130# 在call(后对函数调用换行的penalty 131PenaltyBreakBeforeFirstCallParameter: 19 132# 在一个注释中引入换行的penalty 133PenaltyBreakComment: 300 134# 第一次在<<前换行的penalty 135PenaltyBreakFirstLessLess: 120 136# 在一个字符串字面量中引入换行的penalty 137PenaltyBreakString: 1000 138# 对于每个在行字符数限制之外的字符的penalty 139PenaltyExcessCharacter: 1000000 140# 将函数的返回类型放到它自己的行的penalty 141PenaltyReturnTypeOnItsOwnLine: 120 142# 指针和引用的对齐: Left, Right, Middle 143PointerAlignment: Right 144# 允许重新排版注释 145ReflowComments: true 146# 允许排序#include 147#SortIncludes: Never 148# 在C风格类型转换后添加空格 149SpaceAfterCStyleCast: false 150# 在赋值运算符之前添加空格 151SpaceBeforeAssignmentOperators: true 152# 开圆括号之前添加一个空格: Never, ControlStatements, Always 153SpaceBeforeParens: ControlStatements 154# 在空的圆括号中添加空格 155SpaceInEmptyParentheses: false 156# 在尾随的评论前添加的空格数(只适用于//) 157SpacesBeforeTrailingComments: 1 158# 在尖括号的<后和>前添加空格 159SpacesInAngles: false 160# 在容器(ObjC和JavaScript的数组和字典等)字面量中添加空格 161SpacesInContainerLiterals: true 162# 在C风格类型转换的括号中添加空格 163SpacesInCStyleCastParentheses: false 164# 在圆括号的(后和)前添加空格 165SpacesInParentheses: false 166# 在方括号的[后和]前添加空格,lamda表达式和未指明大小的数组的声明不受影响 167SpacesInSquareBrackets: false 168# 标准: Cpp03, Cpp11, Auto 169Standard: Cpp11 170# tab宽度 171TabWidth: 4 172# 使用tab字符: Never, ForIndentation, ForContinuationAndIndentation, Always 173UseTab: Never