Skip to content

[clang-format] Wrong format for "operator=(...)". #55733

@shrek1402

Description

@shrek1402

I have wrong format:

template<class T>
struct foo{
  void clear_and_delete() noexcept {
    const T* ptr = _wrapped_ptr;
             operator=(nullptr);

    delete ptr;  // NOLINT
  }

  T* _wrapped_ptr;
}

And too:

    void clear_and_delete() noexcept {
      const T* ptr = _wrapped_ptr;
      this->   operator=(nullptr);

      delete ptr;  // NOLINT
    }

my .clang-format file (sorry in advance)

---
Language: Cpp
BasedOnStyle: Google
AccessModifierOffset: 2
AlignAfterOpenBracket: Align
AlignArrayOfStructures: Right
AlignConsecutiveAssignments: Consecutive
AlignConsecutiveBitFields: AcrossEmptyLinesAndComments
AlignConsecutiveDeclarations: Consecutive
AlignConsecutiveMacros: Consecutive
AlignEscapedNewlines: Right
AlignOperands: Align 
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: true
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: None 
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: Inline
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
AttributeMacros: []
BinPackArguments: false
BinPackParameters: false
BitFieldColonSpacing: Both
BreakBeforeBraces: Custom
BraceWrapping:
  AfterCaseLabel: false
  AfterClass: false
  AfterControlStatement: Never 
  AfterEnum: false
  AfterFunction: false
  AfterNamespace: false
  AfterStruct: false
  AfterUnion: false
  AfterExternBlock: false
  BeforeCatch: false
  BeforeElse: false
  BeforeLambdaBody: false
  BeforeWhile: false
  SplitEmptyFunction: true
  SplitEmptyRecord: true
  SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeConceptDeclarations: true
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: AfterColon 
BreakStringLiterals: true
ColumnLimit: 120
CompactNamespaces: true
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ContinuationIndentWidth: 2
Cpp11BracedListStyle: true
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: Always
FixNamespaceComments: true
ForEachMacros: []
IfMacros: []
IncludeBlocks: Regroup
IncludeCategories: 
  - Regex: '^<.*'
    Priority: 1
  - Regex: '^".*'
    Priority: 2
  - Regex: '.*'
    Priority: 3
IncludeIsMainRegex: '([-_](test|unittest))?$'
IndentAccessModifiers: true
IndentCaseBlocks: false
IndentCaseLabels: true
#IndentExternBlock: AfterExternBlock
IndentPPDirectives: BeforeHash
IndentRequires: true
IndentWidth: 2
IndentWrappedFunctionNames: true
InsertTrailingCommas: Wrapped
KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: Signature
#Language: Cpp
MacroBlockBegin: "LIBCPP_BEGIN_NAMESPACE_HASH"
MacroBlockEnd: "LIBCPP_END_NAMESPACE_HASH"
MaxEmptyLinesToKeep: 1
NamespaceIndentation: Inner
NamespaceMacros: []
PackConstructorInitializers: Never
PointerAlignment: Left
QualifierAlignment: Left
# clang 15(?) QualifierOrder: ['inline', 'static', 'const', 'volatile', 'type']
ReferenceAlignment: Left
ReflowComments: True
SeparateDefinitionBlocks: Always
ShortNamespaceLines: 10
SortIncludes: CaseSensitive
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatementsExceptControlMacros
SpaceBeforeRangeBasedForLoopColon: false
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: Never
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: c++17
StatementMacros: []
TabWidth: 2
TypenameMacros: []
UseCRLF: true
UseTab: Never
WhitespaceSensitiveMacros: []
---

Metadata

Metadata

Assignees

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