Skip to content

clang-format inserts line break between constructor name and noexcept #55837

@beinhaerter

Description

@beinhaerter

clang-format 12, 13.0.1 and 14 format structs depending on their struct name.
Rect is formatted as expected/desired, but for RECT and R the noexcept of the constructor is put on the next line. It is not clear why RECT and R are handled differently than Rect.

Here is my C++ code.

struct Rect {
	Rect() noexcept;
};

struct RECT {
	RECT()
	noexcept;
};

struct R {
	R()
	noexcept;
};

And here is the content of my with .clang-format.

AccessModifierOffset: -4
AlignConsecutiveAssignments: AcrossComments
AlignConsecutiveBitFields: AcrossEmptyLinesAndComments
AlignConsecutiveDeclarations: false
AlignConsecutiveMacros: true
AlignOperands: true
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: false
AlwaysBreakTemplateDeclarations: true
BraceWrapping:
  AfterExternBlock: true
  AfterFunction: true
  BeforeCatch: true
  BeforeElse: true
  SplitEmptyFunction: false
  SplitEmptyRecord: false
  SplitEmptyNamespace: false
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: true
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: BeforeComma
ColumnLimit: 0
Cpp11BracedListStyle: false
IndentGotoLabels: false
IndentPPDirectives: BeforeHash
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 5
NamespaceIndentation: All
PointerAlignment: Left
ReflowComments: false
SpaceBeforeSquareBrackets: false
SpacesBeforeTrailingComments: 3
SpacesInConditionalStatement: false
TabWidth: 4
UseTab: true

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviorclang-format

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions