官方文檔:http://clang.llvm.org/docs/ClangFormatStyleOptions.html
中文
在代碼中配置樣式 當使用 clang::format::reformat(...) 方法, 格式將被clang::format::FormatStyle 框架指定。 配置格式化樣式選項 這一部分列出了被支持的選項。 每個操作都有指定類型。 枚舉類型的可能的值,被C++枚舉(一個預編譯,例如:LS_Auto)和配置中的一個值(沒有預編譯:Auto)指定。 BasedOnStyle (string) 這個樣式用於所有沒有特殊指定配置的選項。 這個選項僅在clang-format配置中支持(在-style='{...}' 和 .clang-format 文件里). 可能的值有: LLVM:符合LLVM代碼標准的樣式 Google:符合谷歌的c++樣式指南的樣式 Chromium:符合Chromium樣式指南的樣式 Mozilla:符合Mozilla樣式指南的樣式 WebKit:符合WebKit的樣式指南的樣式 AccessModifierOffset (int) 訪問修飾符的縮進或者向外伸展,例如 public:。 AlignAfterOpenBracket (BracketAlignmentStyle) 如果為真(true),在一個左圓括號后水平對齊參數 這會應用在圓括號,尖括號和中(方)括號。 可能的值有: BAS_Align (在配置中: Align) 在左圓括號后調整參數, 例如: someLongFunction(argument1, argument2); BAS_DontAlign (在配置中: DontAlign) 不調整, 換用 ContinuationIndentWidth, 例如: someLongFunction(argument1, argument2); BAS_AlwaysBreak (在配置中: AlwaysBreak) 在左圓括號后總是換行, 如果參數不能適應單行, 例如: someLongFunction( argument1, argument2); AlignConsecutiveAssignments (bool) 如果為真(true),連續調整多行 這將會調整連續行中的分配操作符。這將會導致像下面這樣的格式: int aaaa = 12; int b = 23; int ccc = 23; AlignConsecutiveDeclarations (bool) 如果為真(true), 校准連續的聲明。 這將會校准連續多行的聲明的名字。這將會導致像下面這樣的格式: int aaaa = 12; float b = 23; std::string ccc = 23; AlignEscapedNewlinesLeft (bool) 如果為真(true), 校准被忽略的新行距左邊盡可能遠。或者把它們放到列的最右邊 AlignOperands (bool) 如果為真(true), 水平對齊二進制和三元表達式的操作數。 具體來說,這將一個表達式的操作數對准一個需要被分割的多行的操作數, 例如: int aaa = bbbbbbbbbbbbbbb + ccccccccccccccc; AlignTrailingComments (bool) 如果為真(true), 對齊注釋。 AllowAllParametersOfDeclarationOnNextLine (bool) 即使BinPackParameters是假的,也允許將一個函數聲明的所有參數移到下一行. AllowShortBlocksOnASingleLine (bool) 允許將簡單的語句塊放到一個單行. 例如, 這允許 將 語句 “if (a) { return; }” 放到一個單行. AllowShortCaseLabelsOnASingleLine (bool) 如果為真(true), 很短的情況下的標簽將會被放到單獨的行。 AllowShortFunctionsOnASingleLine (ShortFunctionStyle) 取決於值, 語句“int f() { return 0; }”可以被放到一個單行。 可能的值有: SFS_None (在配置中: None) 從不合並方法或函數到單獨的一行。 SFS_Empty (在配置中: Empty) 僅合並空的函數。 SFS_Inline (在配置中: Inline) 僅合並類中定義的方法或函數. 意味着 “empty”. SFS_All (在配置中: All) 合並所有的方法適應單行. AllowShortIfStatementsOnASingleLine (bool) 如果為真(true), 語句“if (a) return;” 能被放到單行。 AllowShortLoopsOnASingleLine (bool) 如果為真(true), 語句“while (true) continue;” 能被放到單行。 AlwaysBreakAfterDefinitionReturnType (DefinitionReturnTypeBreakingStyle) 用於函數定義返回類型換行樣式。這個選項是過時的並且被保留向后兼容。 可能的值有: DRTBS_None (在配置中: None) 再返回類型后自動換行。PenaltyReturnTypeOnItsOwnLine 會被考慮到. DRTBS_All (在配置中: All) 總是在返回類型后換行。 DRTBS_TopLevel (在配置中: TopLevel) 總是在返回類型的頂級函數后換行。 AlwaysBreakAfterReturnType (ReturnTypeBreakingStyle) 用於函數聲明返回類型換行樣式。 可能的值有: RTBS_None (在配置中: None) 在返回類型后自動換行。“PenaltyReturnTypeOnItsOwnLine”會被考慮. RTBS_All (在配置中: All) 再返回類型后總是換行。 RTBS_TopLevel (在配置中: TopLevel) 在方法的頂層的返回類型后總是換行。 RTBS_AllDefinitions (在配置中: AllDefinitions) 在方法定義中的返回類型后總是換行。 RTBS_TopLevelDefinitions (在配置中: TopLevelDefinitions) 在頂層定義的返回類型后總是換行。 AlwaysBreakBeforeMultilineStrings (bool) 如果為真(true), 在多行字面量字符串前總是換行。 這個標志意味着使在文件中有多行字符串的情況看起來更一致。因此,如果字符串被“ContinuationIndentWidth”空格導致換行,它將會在行首生效。 AlwaysBreakTemplateDeclarations (bool) 如果為真(true), 在模板聲明“template<...>”后總是換行 BinPackArguments (bool) 如果為假(false), 函數調用的參數要么是在同一行上,要么將在同一行上有一行。 BinPackParameters (bool) 如果為假(false), 函數聲明或函數定義的參數將都在同一行上,或各有一行。 BraceWrapping (BraceWrappingFlags) 控制單獨的大括號換行事件。 如果“BreakBeforeBraces”設置為“BS_Custom”, 使用這個指定如何處理每個單獨的括號的情況。否則,這是被忽略的。 嵌套結構的標志: bool AfterClass 使類定義換行. bool AfterControlStatement 使控制語句(if/for/while/switch/..)換行。 bool AfterEnum 使枚舉定義換行。 bool AfterFunction 使方法定義換行。 bool AfterNamespace 使命名空間定義換行。 bool AfterObjCDeclaration 使OC定義(@autoreleasepool, interfaces, ..)換行。 bool AfterStruct 使結構定義換行。 bool AfterUnion 使共同體定義換行。 bool BeforeCatch 在catch之前換行。 bool BeforeElse 在else之前換行。 bool IndentBraces 縮進換行的大括號。 BreakAfterJavaFieldAnnotations (bool) 在JAVA文件中每個注釋后換行。 BreakBeforeBinaryOperators (BinaryOperatorStyle) 使二進制操作符換行的方法。 可能的值有: BOS_None (在配置中: None) 在操作符后換行。 BOS_NonAssignment (在配置中: NonAssignment) 在操作符沒有被指定前換行。 BOS_All (在配置中: All) 在操作符前換行。 BreakBeforeBraces (BraceBreakingStyle) 用於大括號換行樣式。 可能的值有: BS_Attach (在配置中: Attach) 總是將大括號與上下文連在一起。 BS_Linux (在配置中: Linux) 像Attach一樣, 但是在一個方法、命名空間或一個類定義的大括號之前換行 BS_Mozilla (在配置中: Mozilla) 像Attach一樣, 但是在一個枚舉、方法或記錄定義前換行。 BS_Stroustrup (在配置中: Stroustrup) 像Attach一樣,但是在方法定義、catch、和else前換行 BS_Allman (在配置中: Allman) 總是在大括號之前換行。 BS_GNU (在配置中: GNU) 總是在括號前中斷,並添加一個額外的級別的縮進到控件語句的括號中,而不是類、函數或其他定義的括號中。 BS_WebKit (在配置中: WebKit) 像Attach一樣, 但是在方法前換行。 BS_Custom (在配置中: Custom) 在“BraceWrapping”里配置每一個單獨的大括號。 BreakBeforeTernaryOperators (bool) 如果為真(true), 三元運算符將被放置在換行后。 BreakConstructorInitializersBeforeComma (bool) 總是在逗號和對齊逗號跟冒號前把構造函數初始化式換行。 BreakStringLiterals (bool) 當格式化時,總是對字面量字符串換行。 ColumnLimit (unsigned) 限制列。 列的限制為0意味着沒有列限制。在這種情況下,clang-format將謹慎對待在聲明中輸入行的換行決定,除非與其他規則矛盾。 CommentPragmas (std::string) 一個固定的表達式,它描述了具有特殊意義的注釋,不應該被分裂成行或以其他方式改變。 ConstructorInitializerAllOnOneLineOrOnePerLine (bool) 如果構造函數初始化器不適合在一行,把每個初始化放到單獨的行。 ConstructorInitializerIndentWidth (unsigned) 使用構造函數初始化列表縮進的字符數。 ContinuationIndentWidth (unsigned) 新行縮進寬度。 Cpp11BracedListStyle (bool) 如果為真(true),格式化大括號列表達到最適合c++11列表。 重要區別:-沒有空格內的大括號列表。-大括號關閉前沒有換行。與延續縮進縮進,不與塊縮進。 從根本上講,C++ 11大括號列表與函數調用格式化是一模一樣的。如果大括號列表跟着一個名字(例如類型或變量名),clang-format的格式像是一個調用那個名字的函數的圓括號的“{}”。如果沒有名稱,則假定一個零長度的名稱。 DerivePointerAlignment (bool) 如果為真(true), 分析最常見的格式化文件中“&”和“\*”的對齊方式。pointeralignment則僅作為后備。 DisableFormat (bool) 完全禁止格式化。 ExperimentalAutoDetectBinPacking (bool) 如果為真(true), clang-format檢測函數調用和定義格式化為每行一個參數。 每個調用都可以被包裝,每行一個或不確定的。如果是不確定的,例如完全在一行,但需要做出一個決定,clang-format分析文件中是否有其他被包裝的事例和相應的行動。 注意:這是一個實驗標志,可能會消失或被重命名。不要在配置文件中使用。你自己要為你的使用負責。 ForEachMacros (std::vector<std::string>) 一個宏,應解釋為foreach循環而不是作為函數調用矢量。 這些都是預期形式的宏: FOREACH(<variable-declaration>, ...) <loop-body> 在.clang-format 配置文件中, 這可以被設定為: ForEachMacros: ['RANGES_FOR', 'FOREACH'] 例如: BOOST_FOREACH. IncludeCategories (std::vector<IncludeCategory>) 正則表達式表示不同的#include類別被用於#includes命令。 這些正則表達式與一個包含(包括< >或“)的文件的文件名相匹配。屬於第一匹配正則表達式的值被分配,並且#include首先根據增加類別數然后在每個類別按字母的順序排序。 如果正則表達式都不匹配,int_max分配類別。源文件的主要頭引用自動獲取類別0。因此,它通常是保持在#include開頭(http://llvm.org/docs/CodingStandards.html#include-style)。然而,如果你有總是需要排在首位的頭引用,你也可以分配負面的優先事項。 為了在.clang-format文件中配置這個, 請使用: IncludeCategories: - Regex: '^"(llvm|llvm-c|clang|clang-c)/' Priority: 2 - Regex: '^(<|"(gtest|isl|json)/)' Priority: 3 - Regex: '.\*' Priority: 1 IncludeIsMainRegex (std::string) 指定一個常用的可以在文件主要包括映射的正則表達式的表達式。 在猜測是否#include是“main”include(指定類別0,見上文),使用這個正則表達式允許后綴的頭引用源。部分匹配完成,所以說:-“”意思是任意后綴,-“$”的意思是沒有后綴 例如,如果配置”(_test)?$”,然后.h將被視為包括在a.cc和a_test.ccde中的“main”。 IndentCaseLabels (bool) 從switch語句縮進case標簽一級。 當錯誤時,使用相同的縮進級別作為切換語句。switch語句的語句體總是縮進一級以上的case標簽。 IndentWidth (unsigned) 用於縮進的列數。 IndentWrappedFunctionNames (bool) 縮進如果函數定義或聲明后包的類型。 JavaScriptQuotes (JavaScriptQuoteStyle) JavaScriptQuoteStyle 使用JavaScript字符串。 可能的值有: JSQS_Leave (在配置中: Leave) 留下字符串原本的括號 JSQS_Single (在配置中: Single) 總是使用單括號 JSQS_Double (在配置中: Double) 總是使用雙括號. KeepEmptyLinesAtTheStartOfBlocks (bool) 如果為真(true), 保持塊的起始空行。 Language (LanguageKind) 這種格式針對的是語言。 可能的值有: LK_None (在配置中: None) 不使用 LK_Cpp (在配置中: Cpp) 應該被用於C, C++, ObjectiveC, ObjectiveC++. LK_Java (在配置中: Java) 應該被用於Java. LK_JavaScript (在配置中: JavaScript) 應該被用於 JavaScript. LK_Proto (在配置中: Proto) 應該被用於 Protocol 緩沖 (https://developers.google.com/protocol-buffers/). LK_TableGen (在配置中: TableGen) 應該被用於 TableGen 代碼. MacroBlockBegin (std::string) 匹配宏指令的一個常用於開始一個塊的表達式。 MacroBlockEnd (std::string) 匹配宏指令的一個常用於結束一個塊的表達式。 MaxEmptyLinesToKeep (unsigned) 連續空行的最大數。 NamespaceIndentation (NamespaceIndentationKind) 用於命名空間的縮排。 可能的值有: NI_None (在配置中: None) 在命名空間中不縮進。 NI_Inner (在配置中: Inner) 僅在內部命名空間縮進(嵌套在其他命名空間)。 NI_All (在配置中: All) 在所有的命名空間中縮進。 ObjCBlockIndentWidth (unsigned) OC塊中所拍的字符數。 ObjCSpaceAfterProperty (bool) 在OC中的@property后面添加一個空格。例如:使用“@property (readonly)”而不是“@property(readonly)”。 ObjCSpaceBeforeProtocolList (bool) 在OC協議列表前添加一個空格, 例如: 使用<Protocol>而不是<Protocol>。 PenaltyBreakBeforeFirstCallParameter (unsigned) 在調用小括號“(”后給一個方法調用換行的處罰。 PenaltyBreakComment (unsigned) 包含在一個注釋中的每一個換行的處罰。 PenaltyBreakFirstLessLess (unsigned) 在第一個“<<”前的換行的處罰。 PenaltyBreakString (unsigned) 包含一個字面量的字符串中的每一個換行的處罰。 PenaltyExcessCharacter (unsigned) 每一個字符的列限制外的處罰。 PenaltyReturnTypeOnItsOwnLine (unsigned) 把一個方法返回類型放到函數的同一行。 PointerAlignment (PointerAlignmentStyle) 指針和引用的對其方式。 可能的值有: PAS_Left (在配置中: Left) 指針左對齊。 PAS_Right (在配置中: Right) 指針右對齊。 PAS_Middle (在配置中: Middle) 指針中間對齊。 ReflowComments (bool) 如果為真(true), clang-format 將會嘗試將注釋重新流布局。 SortIncludes (bool) 如果為真(true), clang-format 將會分類#includes. SpaceAfterCStyleCast (bool) 如果為真(true), 可能在一個C樣式描述后插入一個空格。 SpaceAfterTemplateKeyword (bool) 如果為真(true), 在“template”關鍵字后插入一個空格。 SpaceBeforeAssignmentOperators (bool) 如果為假(false),移除分配操作符(=)前空格。 SpaceBeforeParens (SpaceBeforeParensOptions) 大括號之前定義空格的情況。 可能的值有: SBPO_Never (在配置中: Never) 從不在圓括號之前加空格。 SBPO_ControlStatements (在配置中: ControlStatements) 僅在控制聲明關鍵詞(for/if/while···)的圓括號前面加空格。 SBPO_Always (在配置中: Always) 總在圓括號前面加空格, 除了語法規則禁止的(在方法中-像宏定義)或者 當其他樣式規則定義過的(在一元運算符后,圓括號, 等等) SpaceInEmptyParentheses (bool) 如果為真(true), 可能會在“()”中插入空格。 SpacesBeforeTrailingComments (unsigned) 單行注釋前的空格數(// - comments)。 這不會影響塊注釋(/* - comments),因為它們通常會有不同的使用模式和一些特殊情況。 SpacesInAngles (bool) 如果為真(true), 將會在模板對齊列的“<>”中間插入空格。 SpacesInCStyleCastParentheses (bool) 如果為真(true), 將會在C樣式描述中插入空格。 SpacesInContainerLiterals (bool) 如果為真(true), 將會在字面量容器中插入空格(例如 OC和Javascript的數組和字典字面量)。 SpacesInParentheses (bool) 如果為真(true), 將會在“(”之后和“)”之前插入空格。 SpacesInSquareBrackets (bool) 如果為真(true),將會在“[”之后和“]”之前插入空格。 Standard (LanguageStandard) 用這個標准格式化:例如:在LS_Cpp03中使用 A<A<int> > 而不是 A<A<int>> 可能的值有: LS_Cpp03 (在配置中: Cpp03) 使用Use C++03統一語法。 LS_Cpp11 (在配置中: Cpp11) 使用C++11的特征(例如 A<A<int>>而不是A<A<int> >). LS_Auto (在配置中: Auto) 基於輸入自動檢查。 TabWidth (unsigned) 用於制表符停止的列數。 UseTab (UseTabStyle) 在結果文件中使用制表符字符的方式。 可能的值有: UT_Never (在配置中: Never) 從不使用制表符。 UT_ForIndentation (在配置中: ForIndentation) 僅縮排時使用制表符。 UT_Always (在配置中: Always) 使用標簽時,我們需要填補的空白,至少從一個制表位到下一個。
英文
Configuring Style in Code When using clang::format::reformat(...) functions, the format is specified by supplying the clang::format::FormatStyle structure. Configurable Format Style Options This section lists the supported style options. Value type is specified for each option. For enumeration types possible values are specified both as a C++ enumeration member (with a prefix, e.g. LS_Auto), and as a value usable in the configuration (without a prefix: Auto). BasedOnStyle (string) The style used for all options not specifically set in the configuration. This option is supported only in the clang-format configuration (both within -style='{...}' and the .clang-format file). Possible values: LLVM A style complying with the LLVM coding standards Google A style complying with Google’s C++ style guide Chromium A style complying with Chromium’s style guide Mozilla A style complying with Mozilla’s style guide WebKit A style complying with WebKit’s style guide AccessModifierOffset (int) The extra indent or outdent of access modifiers, e.g. public:. AlignAfterOpenBracket (BracketAlignmentStyle) If true, horizontally aligns arguments after an open bracket. This applies to round brackets (parentheses), angle brackets and square brackets. Possible values: BAS_Align (in configuration: Align) Align parameters on the open bracket, e.g.: someLongFunction(argument1, argument2); BAS_DontAlign (in configuration: DontAlign) Don’t align, instead use ContinuationIndentWidth, e.g.: someLongFunction(argument1, argument2); BAS_AlwaysBreak (in configuration: AlwaysBreak) Always break after an open bracket, if the parameters don’t fit on a single line, e.g.: someLongFunction( argument1, argument2); AlignConsecutiveAssignments (bool) If true, aligns consecutive assignments. This will align the assignment operators of consecutive lines. This will result in formattings like int aaaa = 12; int b = 23; int ccc = 23; AlignConsecutiveDeclarations (bool) If true, aligns consecutive declarations. This will align the declaration names of consecutive lines. This will result in formattings like int aaaa = 12; float b = 23; std::string ccc = 23; AlignEscapedNewlinesLeft (bool) If true, aligns escaped newlines as far left as possible. Otherwise puts them into the right-most column. AlignOperands (bool) If true, horizontally align operands of binary and ternary expressions. Specifically, this aligns operands of a single expression that needs to be split over multiple lines, e.g.: int aaa = bbbbbbbbbbbbbbb + ccccccccccccccc; AlignTrailingComments (bool) If true, aligns trailing comments. AllowAllParametersOfDeclarationOnNextLine (bool) Allow putting all parameters of a function declaration onto the next line even if BinPackParameters is false. AllowShortBlocksOnASingleLine (bool) Allows contracting simple braced statements to a single line. E.g., this allows if (a) { return; } to be put on a single line. AllowShortCaseLabelsOnASingleLine (bool) If true, short case labels will be contracted to a single line. AllowShortFunctionsOnASingleLine (ShortFunctionStyle) Dependent on the value, int f() { return 0; } can be put on a single line. Possible values: SFS_None (in configuration: None) Never merge functions into a single line. SFS_Empty (in configuration: Empty) Only merge empty functions. SFS_Inline (in configuration: Inline) Only merge functions defined inside a class. Implies “empty”. SFS_All (in configuration: All) Merge all functions fitting on a single line. AllowShortIfStatementsOnASingleLine (bool) If true, if (a) return; can be put on a single line. AllowShortLoopsOnASingleLine (bool) If true, while (true) continue; can be put on a single line. AlwaysBreakAfterDefinitionReturnType (DefinitionReturnTypeBreakingStyle) The function definition return type breaking style to use. This option is deprecated and is retained for backwards compatibility. Possible values: DRTBS_None (in configuration: None) Break after return type automatically. PenaltyReturnTypeOnItsOwnLine is taken into account. DRTBS_All (in configuration: All) Always break after the return type. DRTBS_TopLevel (in configuration: TopLevel) Always break after the return types of top-level functions. AlwaysBreakAfterReturnType (ReturnTypeBreakingStyle) The function declaration return type breaking style to use. Possible values: RTBS_None (in configuration: None) Break after return type automatically. PenaltyReturnTypeOnItsOwnLine is taken into account. RTBS_All (in configuration: All) Always break after the return type. RTBS_TopLevel (in configuration: TopLevel) Always break after the return types of top-level functions. RTBS_AllDefinitions (in configuration: AllDefinitions) Always break after the return type of function definitions. RTBS_TopLevelDefinitions (in configuration: TopLevelDefinitions) Always break after the return type of top-level definitions. AlwaysBreakBeforeMultilineStrings (bool) If true, always break before multiline string literals. This flag is mean to make cases where there are multiple multiline strings in a file look more consistent. Thus, it will only take effect if wrapping the string at that point leads to it being indented ContinuationIndentWidth spaces from the start of the line. AlwaysBreakTemplateDeclarations (bool) If true, always break after the template<...> of a template declaration. BinPackArguments (bool) If false, a function call’s arguments will either be all on the same line or will have one line each. BinPackParameters (bool) If false, a function declaration’s or function definition’s parameters will either all be on the same line or will have one line each. BraceWrapping (BraceWrappingFlags) Control of individual brace wrapping cases. If BreakBeforeBraces is set to BS_Custom, use this to specify how each individual brace case should be handled. Otherwise, this is ignored. Nested configuration flags: bool AfterClass Wrap class definitions. bool AfterControlStatement Wrap control statements (if/for/while/switch/..). bool AfterEnum Wrap enum definitions. bool AfterFunction Wrap function definitions. bool AfterNamespace Wrap namespace definitions. bool AfterObjCDeclaration Wrap ObjC definitions (@autoreleasepool, interfaces, ..). bool AfterStruct Wrap struct definitions. bool AfterUnion Wrap union definitions. bool BeforeCatch Wrap before catch. bool BeforeElse Wrap before else. bool IndentBraces Indent the wrapped braces themselves. BreakAfterJavaFieldAnnotations (bool) Break after each annotation on a field in Java files. BreakBeforeBinaryOperators (BinaryOperatorStyle) The way to wrap binary operators. Possible values: BOS_None (in configuration: None) Break after operators. BOS_NonAssignment (in configuration: NonAssignment) Break before operators that aren’t assignments. BOS_All (in configuration: All) Break before operators. BreakBeforeBraces (BraceBreakingStyle) The brace breaking style to use. Possible values: BS_Attach (in configuration: Attach) Always attach braces to surrounding context. BS_Linux (in configuration: Linux) Like Attach, but break before braces on function, namespace and class definitions. BS_Mozilla (in configuration: Mozilla) Like Attach, but break before braces on enum, function, and record definitions. BS_Stroustrup (in configuration: Stroustrup) Like Attach, but break before function definitions, catch, and else. BS_Allman (in configuration: Allman) Always break before braces. BS_GNU (in configuration: GNU) Always break before braces and add an extra level of indentation to braces of control statements, not to those of class, function or other definitions. BS_WebKit (in configuration: WebKit) Like Attach, but break before functions. BS_Custom (in configuration: Custom) Configure each individual brace in BraceWrapping. BreakBeforeTernaryOperators (bool) If true, ternary operators will be placed after line breaks. BreakConstructorInitializersBeforeComma (bool) Always break constructor initializers before commas and align the commas with the colon. BreakStringLiterals (bool) Allow breaking string literals when formatting. ColumnLimit (unsigned) The column limit. A column limit of 0 means that there is no column limit. In this case, clang-format will respect the input’s line breaking decisions within statements unless they contradict other rules. CommentPragmas (std::string) A regular expression that describes comments with special meaning, which should not be split into lines or otherwise changed. ConstructorInitializerAllOnOneLineOrOnePerLine (bool) If the constructor initializers don’t fit on a line, put each initializer on its own line. ConstructorInitializerIndentWidth (unsigned) The number of characters to use for indentation of constructor initializer lists. ContinuationIndentWidth (unsigned) Indent width for line continuations. Cpp11BracedListStyle (bool) If true, format braced lists as best suited for C++11 braced lists. Important differences: - No spaces inside the braced list. - No line break before the closing brace. - Indentation with the continuation indent, not with the block indent. Fundamentally, C++11 braced lists are formatted exactly like function calls would be formatted in their place. If the braced list follows a name (e.g. a type or variable name), clang-format formats as if the {} were the parentheses of a function call with that name. If there is no name, a zero-length name is assumed. DerivePointerAlignment (bool) If true, analyze the formatted file for the most common alignment of & and \*. PointerAlignment is then used only as fallback. DisableFormat (bool) Disables formatting completely. ExperimentalAutoDetectBinPacking (bool) If true, clang-format detects whether function calls and definitions are formatted with one parameter per line. Each call can be bin-packed, one-per-line or inconclusive. If it is inconclusive, e.g. completely on one line, but a decision needs to be made, clang-format analyzes whether there are other bin-packed cases in the input file and act accordingly. NOTE: This is an experimental flag, that might go away or be renamed. Do not use this in config files, etc. Use at your own risk. ForEachMacros (std::vector<std::string>) A vector of macros that should be interpreted as foreach loops instead of as function calls. These are expected to be macros of the form: FOREACH(<variable-declaration>, ...) <loop-body> In the .clang-format configuration file, this can be configured like: ForEachMacros: ['RANGES_FOR', 'FOREACH'] For example: BOOST_FOREACH. IncludeCategories (std::vector<IncludeCategory>) Regular expressions denoting the different #include categories used for ordering #includes. These regular expressions are matched against the filename of an include (including the <> or “”) in order. The value belonging to the first matching regular expression is assigned and #includes are sorted first according to increasing category number and then alphabetically within each category. If none of the regular expressions match, INT_MAX is assigned as category. The main header for a source file automatically gets category 0. so that it is generally kept at the beginning of the #includes (http://llvm.org/docs/CodingStandards.html#include-style). However, you can also assign negative priorities if you have certain headers that always need to be first. To configure this in the .clang-format file, use: IncludeCategories: - Regex: '^"(llvm|llvm-c|clang|clang-c)/' Priority: 2 - Regex: '^(<|"(gtest|isl|json)/)' Priority: 3 - Regex: '.\*' Priority: 1 IncludeIsMainRegex (std::string) Specify a regular expression of suffixes that are allowed in the file-to-main-include mapping. When guessing whether a #include is the “main” include (to assign category 0, see above), use this regex of allowed suffixes to the header stem. A partial match is done, so that: - “” means “arbitrary suffix” - “$” means “no suffix” For example, if configured to “(_test)?$”, then a header a.h would be seen as the “main” include in both a.cc and a_test.cc. IndentCaseLabels (bool) Indent case labels one level from the switch statement. When false, use the same indentation level as for the switch statement. Switch statement body is always indented one level more than case labels. IndentWidth (unsigned) The number of columns to use for indentation. IndentWrappedFunctionNames (bool) Indent if a function definition or declaration is wrapped after the type. JavaScriptQuotes (JavaScriptQuoteStyle) The JavaScriptQuoteStyle to use for JavaScript strings. Possible values: JSQS_Leave (in configuration: Leave) Leave string quotes as they are. JSQS_Single (in configuration: Single) Always use single quotes. JSQS_Double (in configuration: Double) Always use double quotes. KeepEmptyLinesAtTheStartOfBlocks (bool) If true, empty lines at the start of blocks are kept. Language (LanguageKind) Language, this format style is targeted at. Possible values: LK_None (in configuration: None) Do not use. LK_Cpp (in configuration: Cpp) Should be used for C, C++, ObjectiveC, ObjectiveC++. LK_Java (in configuration: Java) Should be used for Java. LK_JavaScript (in configuration: JavaScript) Should be used for JavaScript. LK_Proto (in configuration: Proto) Should be used for Protocol Buffers (https://developers.google.com/protocol-buffers/). LK_TableGen (in configuration: TableGen) Should be used for TableGen code. MacroBlockBegin (std::string) A regular expression matching macros that start a block. MacroBlockEnd (std::string) A regular expression matching macros that end a block. MaxEmptyLinesToKeep (unsigned) The maximum number of consecutive empty lines to keep. NamespaceIndentation (NamespaceIndentationKind) The indentation used for namespaces. Possible values: NI_None (in configuration: None) Don’t indent in namespaces. NI_Inner (in configuration: Inner) Indent only in inner namespaces (nested in other namespaces). NI_All (in configuration: All) Indent in all namespaces. ObjCBlockIndentWidth (unsigned) The number of characters to use for indentation of ObjC blocks. ObjCSpaceAfterProperty (bool) Add a space after @property in Objective-C, i.e. use @property (readonly) instead of @property(readonly). ObjCSpaceBeforeProtocolList (bool) Add a space in front of an Objective-C protocol list, i.e. use Foo <Protocol> instead of Foo<Protocol>. PenaltyBreakBeforeFirstCallParameter (unsigned) The penalty for breaking a function call after call(. PenaltyBreakComment (unsigned) The penalty for each line break introduced inside a comment. PenaltyBreakFirstLessLess (unsigned) The penalty for breaking before the first <<. PenaltyBreakString (unsigned) The penalty for each line break introduced inside a string literal. PenaltyExcessCharacter (unsigned) The penalty for each character outside of the column limit. PenaltyReturnTypeOnItsOwnLine (unsigned) Penalty for putting the return type of a function onto its own line. PointerAlignment (PointerAlignmentStyle) Pointer and reference alignment style. Possible values: PAS_Left (in configuration: Left) Align pointer to the left. PAS_Right (in configuration: Right) Align pointer to the right. PAS_Middle (in configuration: Middle) Align pointer in the middle. ReflowComments (bool) If true, clang-format will attempt to re-flow comments. SortIncludes (bool) If true, clang-format will sort #includes. SpaceAfterCStyleCast (bool) If true, a space may be inserted after C style casts. SpaceAfterTemplateKeyword (bool) If true, a space will be inserted after the ‘template’ keyword. SpaceBeforeAssignmentOperators (bool) If false, spaces will be removed before assignment operators. SpaceBeforeParens (SpaceBeforeParensOptions) Defines in which cases to put a space before opening parentheses. Possible values: SBPO_Never (in configuration: Never) Never put a space before opening parentheses. SBPO_ControlStatements (in configuration: ControlStatements) Put a space before opening parentheses only after control statement keywords (for/if/while...). SBPO_Always (in configuration: Always) Always put a space before opening parentheses, except when it’s prohibited by the syntax rules (in function-like macro definitions) or when determined by other style rules (after unary operators, opening parentheses, etc.) SpaceInEmptyParentheses (bool) If true, spaces may be inserted into (). SpacesBeforeTrailingComments (unsigned) The number of spaces before trailing line comments (// - comments). This does not affect trailing block comments (/* - comments) as those commonly have different usage patterns and a number of special cases. SpacesInAngles (bool) If true, spaces will be inserted after < and before > in template argument lists. SpacesInCStyleCastParentheses (bool) If true, spaces may be inserted into C style casts. SpacesInContainerLiterals (bool) If true, spaces are inserted inside container literals (e.g. ObjC and Javascript array and dict literals). SpacesInParentheses (bool) If true, spaces will be inserted after ( and before ). SpacesInSquareBrackets (bool) If true, spaces will be inserted after [ and before ]. Standard (LanguageStandard) Format compatible with this standard, e.g. use A<A<int> > instead of A<A<int>> for LS_Cpp03. Possible values: LS_Cpp03 (in configuration: Cpp03) Use C++03-compatible syntax. LS_Cpp11 (in configuration: Cpp11) Use features of C++11 (e.g. A<A<int>> instead of A<A<int> >). LS_Auto (in configuration: Auto) Automatic detection based on the input. TabWidth (unsigned) The number of columns used for tab stops. UseTab (UseTabStyle) The way to use tab characters in the resulting file. Possible values: UT_Never (in configuration: Never) Never use tab. UT_ForIndentation (in configuration: ForIndentation) Use tabs only for indentation. UT_Always (in configuration: Always) Use tabs whenever we need to fill whitespace that spans at least from one tab stop to the next one.
******
后面的內容與標題無關 推廣下個人開發的APP 覺得還不錯的 自己自己偷偷用就行了