首页 > 其他分享 >clang-format的代码格式化

clang-format的代码格式化

时间:2024-10-07 11:44:24浏览次数:1  
标签:llvm false format AcrossEmptyLines clang 格式化 true


1. VS Code

settings.json

{
  "C_Cpp.default.intelliSenseMode": "windows-msvc-x64",
  // "C_Cpp.clang_format_fallbackStyle": "Google",
  "C_Cpp.clang_format_path": "D:/software/clang+llvm-18.1.8-x86_64-pc-windows-msvc/bin/clang-format.exe",
  "C_Cpp.clang_format_style": "file:D:/software/clang+llvm-18.1.8-x86_64-pc-windows-msvc/.vscode/.clang-format-microsoft",
  "clangd.enableCodeCompletion": false,


}

在这里插入图片描述



2. Visual Studio

可以根据编码规范或自己喜好进行修改,.clang-format文件将放到XXX.sln相同目录


3. .clang-format-microsoft

# Microsoft
D:/software/clang+llvm-18.1.8-x86_64-pc-windows-msvc/bin/clang-format.exe   -style=Microsoft  -dump-config > .clang-format-microsoft

# Google
D:/software/clang+llvm-18.1.8-x86_64-pc-windows-msvc/bin/clang-format.exe   -style=google -dump-config > .clang-format-google



.clang-format-microsoft文件

---
Language:        Cpp
# BasedOnStyle:  Microsoft
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignArrayOfStructures: None
AlignConsecutiveAssignments:
  Enabled:         false
  AcrossEmptyLines: false
  AcrossComments:  false
  AlignCompound:   false
  AlignFunctionPointers: false
  PadOperators:    true
AlignConsecutiveBitFields:
  Enabled:         false
  AcrossEmptyLines: false
  AcrossComments:  false
  AlignCompound:   false
  AlignFunctionPointers: false
  PadOperators:    false
AlignConsecutiveDeclarations:
  Enabled:         false
  AcrossEmptyLines: false
  AcrossComments:  false
  AlignCompound:   false
  AlignFunctionPointers: false
  PadOperators:    false
AlignConsecutiveMacros:
  Enabled:         false
  AcrossEmptyLines: false
  AcrossComments:  false
  AlignCompound:   false
  AlignFunctionPointers: false
  PadOperators:    false
AlignConsecutiveShortCaseStatements:
  Enabled:         false
  AcrossEmptyLines: false
  AcrossComments:  false
  AlignCaseColons: false
AlignEscapedNewlines: Right
AlignOperands:   Align
AlignTrailingComments:
  Kind:            Always
  OverEmptyLines:  0
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowBreakBeforeNoexceptSpecifier: Never
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortCompoundRequirementOnASingleLine: true
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
AttributeMacros:
  - __capability
BinPackArguments: true
BinPackParameters: true
BitFieldColonSpacing: Both
BraceWrapping:
  AfterCaseLabel:  false
  AfterClass:      true
  AfterControlStatement: Always
  AfterEnum:       true
  AfterExternBlock: true
  AfterFunction:   true
  AfterNamespace:  true
  AfterObjCDeclaration: true
  AfterStruct:     true
  AfterUnion:      false
  BeforeCatch:     true
  BeforeElse:      true
  BeforeLambdaBody: false
  BeforeWhile:     false
  IndentBraces:    false
  SplitEmptyFunction: true
  SplitEmptyRecord: true
  SplitEmptyNamespace: true
BreakAdjacentStringLiterals: true
BreakAfterAttributes: Leave
BreakAfterJavaFieldAnnotations: false
BreakArrays:     true
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: Always
BreakBeforeBraces: Custom
BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BreakStringLiterals: true
ColumnLimit:     1024000
CommentPragmas:  '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat:   false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
  - foreach
  - Q_FOREACH
  - BOOST_FOREACH
IfMacros:
  - KJ_IF_MAYBE
IncludeBlocks:   Preserve
IncludeCategories:
  - Regex:           '^"(llvm|llvm-c|clang|clang-c)/'
    Priority:        2
    SortPriority:    0
    CaseSensitive:   false
  - Regex:           '^(<|"(gtest|gmock|isl|json)/)'
    Priority:        3
    SortPriority:    0
    CaseSensitive:   false

  - Regex:           '.*'
    Priority:        1
    SortPriority:    0
    CaseSensitive:   false
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: false
IndentExternBlock: AfterExternBlock
IndentGotoLabels: true
IndentPPDirectives: None
IndentRequiresClause: true
IndentWidth:     2
IndentWrappedFunctionNames: false
InsertBraces:    false
InsertNewlineAtEOF: false
InsertTrailingCommas: None
IntegerLiteralSeparator:
  Binary:          0
  BinaryMinDigits: 0
  Decimal:         0
  DecimalMinDigits: 0
  Hex:             0
  HexMinDigits:    0
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
KeepEmptyLinesAtEOF: false
LambdaBodyIndentation: Signature
LineEnding:      DeriveLF
MacroBlockBegin: ''
MacroBlockEnd:   ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PackConstructorInitializers: BinPack
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
PenaltyBreakScopeResolution: 500
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyIndentedWhitespace: 0
PenaltyReturnTypeOnItsOwnLine: 1000
PointerAlignment: Right
PPIndentWidth:   -1
QualifierAlignment: Leave
ReferenceAlignment: Pointer
ReflowComments:  true
RemoveBracesLLVM: false
RemoveParentheses: Leave
RemoveSemicolon: false
RequiresClausePosition: OwnLine
RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1
SkipMacroDefinitionBody: false
SortIncludes:    CaseSensitive
SortJavaStaticImport: Before
SortUsingDeclarations: LexicographicNumeric
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeJsonColon: false
SpaceBeforeParens: ControlStatements
SpaceBeforeParensOptions:
  AfterControlStatements: true
  AfterForeachMacros: true
  AfterFunctionDefinitionName: false
  AfterFunctionDeclarationName: false
  AfterIfMacros:   true
  AfterOverloadedOperator: false
  AfterPlacementOperator: true
  AfterRequiresInClause: false
  AfterRequiresInExpression: false
  BeforeNonEmptyParentheses: false
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpacesBeforeTrailingComments: 1
SpacesInAngles:  Never
SpacesInContainerLiterals: true
SpacesInLineCommentPrefix:
  Minimum:         1
  Maximum:         -1
SpacesInParens:  Never
SpacesInParensOptions:
  InCStyleCasts:   false
  InConditionalStatements: false
  InEmptyParentheses: false
  Other:           false
SpacesInSquareBrackets: false
Standard:        Latest
StatementAttributeLikeMacros:
  - Q_EMIT
StatementMacros:
  - Q_UNUSED
  - QT_REQUIRE_VERSION
TabWidth:        4
UseTab:          Never
VerilogBreakBetweenInstancePorts: true
WhitespaceSensitiveMacros:
  - BOOST_PP_STRINGIZE
  - CF_SWIFT_NAME
  - NS_SWIFT_NAME
  - PP_STRINGIZE
  - STRINGIZE
...


-------------

标签:llvm,false,format,AcrossEmptyLines,clang,格式化,true
From: https://www.cnblogs.com/gispathfinder/p/18449869

相关文章

  • WPF string format
    Text="{BindingStringFormat={}{0}items,Source={StaticResourcemainVM},Path=Cnt}"                //xaml<Windowx:Class="WpfApp17.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/pre......
  • 数据格式化汇总
    数值格式化1.1设置小数点位数df['column_name']=df['column_name'].round(2)#保留两位小数1.2使用apply自定义格式化df['column_name']=df['column_name'].apply(lambdax:'{:,.2f}'.format(x))#逗号分隔符1.3格式化为百分比d......
  • 格式化文档
    1.清除尾部参考文献和头部封面及目录2.去除水印3.去除右边所有船锚(宏),清除嵌入对象(宏),去除表格(宏),去除所有图形SubDeleteAllShapes()DimshpAsShapeForEachshpInActiveDocument.Shapesshp.DeleteNextshpEndSubSubDeleteAllInlineShapesAndS......
  • python 包含有引号和花括号的字符串的格式化
    replace不起作用;update_per_seconds="30"uploadtime_per_seconds="30"imei_string="1234"###采用{0}format不行###下面replace不行msg="""{"rmtcmd":"set","dev":{"poll":{&......
  • u盘格式化后数据能恢复吗?2024年Top4恢复神器来帮忙
    在这个电脑和手机满天飞的时代,U盘是我们用来存东西和传文件的得力助手,特别重要。但是,有时候U盘可能会不小心被格式化了,里面的重要文件就不见了。那么,U盘格式化后的数据还能恢复吗?当然可以。今天会告诉你2024年厉害的四个U盘数据恢复工具,帮你轻松找回不小心弄丢的数据。1.福昕......
  • WPF Progrss bar stringformat {} {0}% IsDetermined
    //xaml<Windowx:Class="WpfApp425.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.mi......
  • JS实现String.Format
    js实现string.format功能<scripttype="text/javascript">varerrorHtml="<atitle=\"{1}\"href=\"#\"onclick=\"\"class=\"ml-5\"style=\"text-decoration:none;color:#FF3C3......
  • 【Java】—— 常用类和基础API:JDK8之前日期时间API的使用:Date、SimpleDateFormat、Cal
    目录3.JDK8之前:日期时间API3.1java.lang.System类的方法3.2java.util.Date3.3java.text.SimpleDateFormat3.4java.util.Calendar(日历)练习3.JDK8之前:日期时间API3.1java.lang.System类的方法System类提供的publicstaticlongcurrentTimeMillis():用来返......
  • 2、HTML 常用文本格式化标签
    学习是一场马拉松,不在于瞬间的爆发,而在于途中的坚持。文章目录HTML常用文本格式化标签前言1.标签汇总2.示例代码3.运行截图HTML常用文本格式化标签前言HTML中的文本格式化标签,可以为文字设置租体、斜体或下划线等效果,使文字以特殊的方式显示,以此和普通文......
  • JS 检测代码格式化
         https://www.cnblogs.com/kai-/p/16935788.html    console.log("start");functiont(){returnt.toString().search('(((.+)+)+)+$').toString();}a=t();console.log("end");  console.log("start");......