Hi Adam,

I've been trying to make a clang-format for NuttX however I did run in some 
nasty bugs with clang-format.
Mostly the inconsistent spacing caused by preprocessor directives (#ifdef) etc.
I've filed a bug on the LLVM bugtracker 
(https://bugs.llvm.org/show_bug.cgi?id=44843) unfortunely I didn't get any 
response.
Please find below the clang-format I've used, I would say it's 80% done.
But it's mostly that NXStyle requires special things that clang-format doesn’t 
provide.

---
AccessModifierOffset: -6
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: 'true'
AlignConsecutiveDeclarations: 'false'
AlignEscapedNewlines: DontAlign
AlignTrailingComments: 'true'
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: 'false'
AllowShortLoopsOnASingleLine: 'false'
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: AllDefinitions
BreakBeforeBinaryOperators: None
BraceWrapping:
  AfterCaseLabel:  true
  AfterClass:      true
  AfterControlStatement: true
  AfterEnum:       true
  AfterFunction:   true
  AfterNamespace:  true
  AfterObjCDeclaration: true
  AfterStruct:     true
  AfterUnion:      true
  BeforeCatch:     true
  BeforeElse:      true
  IndentBraces:    true
  SplitEmptyFunction: true
  SplitEmptyRecord: true
  SplitEmptyNamespace: true
BreakBeforeBraces: Custom
ColumnLimit: 77
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerIndentWidth: '0'
ContinuationIndentWidth: 2
IncludeIsMainRegex: (Test)?$
IndentPPDirectives: AfterHash
IndentWidth: '2'
JavaScriptQuotes: Leave
MaxEmptyLinesToKeep: 2
NamespaceIndentation: None
ObjCBlockIndentWidth: '3'
PenaltyBreakBeforeFirstCallParameter: '32'
PenaltyBreakComment: 0
PenaltyBreakFirstLessLess: '44'
PenaltyBreakString: 838
PenaltyExcessCharacter: '399916'
PenaltyReturnTypeOnItsOwnLine: 30
PointerAlignment: Right
ReflowComments: 'true'
SortIncludes: 'false'
SpaceAfterCStyleCast: 'false'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: 'false'
SpacesBeforeTrailingComments: 1
SpacesInCStyleCastParentheses: 'false'
SpacesInParentheses: 'false'
SpacesInSquareBrackets: 'false'
Standard: Cpp11
TabWidth: '4'
UseTab: Never
...

> Thanks David. I'll try your approach. If there are some things that don't 
> quite work with Clang-Format (I already found a few) I'll see about adding a 
> fixup script pass at the end, or contributing some rules back to Clang.
> 
> I'll try your idea about combining all the files under sched into a set.
> 
> When you said you got 95% of the way there, do you have a .clang-format file 
> that I could use as a starting point? If so that would help me start where 
> you left off.
> 
>cheers
>adam

Reply via email to