Skip to content

clang-format indents class member functions oddly if there are function-like macro invocations #123142

@alanzhao1

Description

@alanzhao1

Given

class PA_LOCKABLE Lock {
public:
  void Acquire() PA_EXCLUSIVE_LOCK_FUNCTION() {}
  void Release() PA_UNLOCK_FUNCTION() {}
};

where PA_LOCKABLE, PA_EXCLUSIVE_LOCK_FUNCTION(), and PA_UNLOCK_FUNCTION() are macros,

clang-format returns

class PA_LOCKABLE Lock{
  public : void Acquire() PA_EXCLUSIVE_LOCK_FUNCTION(){} void Release()
      PA_UNLOCK_FUNCTION(){}
};

The main issues are:

  • A space is added before and after the colon after public
  • The space is removed between the class name and the curly bracket
  • Very strange indentation and newlining of the two member functions

This regression occurred somewhere between 1066481 and 29ed600

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions