Skip to content

[clang-format] Lack of space after 'not' operator before parens since clang-format-20 #149971

@stroju

Description

@stroju

Change #135035 seems to be messing with for formatting of not works.

When SpaceAfterLogicalNot: true on 19.1.7 then output was:

bool operator!=(const A& r) const { return not (*this == r); }

while version 20.1.7 formats it as

bool operator!=(const A& r) const { return not(*this == r); }

! works as before, while not seems to treated like symbol (function).

Is this intentional that SpaceAfterLogicalNot does not reflect any changes to not operator?

If so, how can we control this behavior so we can keep space after not?

My configuration:

Specific to the directory where file is:

Language: Cpp
InsertBraces: true
InsertNewlineAtEOF: true
KeepEmptyLines:
AtEndOfFile: false
AtStartOfBlock: false
AtStartOfFile: false
LineEnding: LF
SpaceAfterLogicalNot: true
SpacesInParens: Never

Basic config:

Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignOperands: false
AlignTrailingComments: false
AlignEscapedNewlinesLeft: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: true
BreakStringLiterals: true
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DisableFormat: false
FixNamespaceComments: true
IncludeCategories:

  • Regex: '^<sys/'
    Priority: 1
  • Regex: '^<'
    Priority: 2
  • Regex: '^"'
    Priority: 3
    IndentCaseLabels: true
    KeepEmptyLinesAtTheStartOfBlocks: false
    MaxEmptyLinesToKeep: 1
    BraceWrapping:
    AfterNamespace: false
    AfterUnion: true
    NamespaceIndentation: None
    PenaltyReturnTypeOnItsOwnLine: 5000
    PointerAlignment: Left
    SortIncludes: true
    SpaceBeforeAssignmentOperators: true
    SpaceBeforeParens: ControlStatements
    SpaceInEmptyParentheses: false
    Standard: Cpp11

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions