llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[clang-format] Add flag to suppress empty line insertion before access modifier.

Open silvasean opened this issue 13 years ago • 6 comments

Bugzilla Link 16518
Version trunk
OS All
CC @mydeveloperday

Extended Description

Before:

class X {
  int Y;
public:
  int Z;
};

After:

class X {
  int Y;

public:
  int Z;
};

It would be nice if clang-format had an option to suppress this behavior.

silvasean avatar Jul 02 '13 01:07 silvasean

mentioned in issue llvm/llvm-bugzilla-archive#41870

llvmbot avatar Nov 27 '21 01:11 llvmbot

Would you like to submit this patch?

https://llvm.org/docs/Contributing.html

If so feel free to add me as a reviewer

mydeveloperday avatar Dec 27 '20 15:12 mydeveloperday

Patch which adds option to disable forced insertion of empty line before access modifiers. Attached patch adds new option called InsertEmptyLineBeforeAccessModifier. Empty line before access modifier is inserted if this option is set to true (which is the default value, because clang-format always inserts empty lines before access modifiers), otherwise empty lines are removed.

I do not know if it is enough to have a boolean value, or a third value is needed to disable both behaviors (neither insert, nor remove empty lines before access modifiers).

llvmbot avatar Dec 21 '20 17:12 llvmbot

Patches are welcome :-).

llvmbot avatar Aug 28 '13 10:08 llvmbot

Is this issue fixed? I'd like to work on it. I'm a beginner and novice so help and guidance would be appreciated

Shanchax avatar Jul 04 '23 05:07 Shanchax

I think this issue is fixed in https://github.com/llvm/llvm-project/commit/60bf5826cfd3629b5200a8ab743d701c90f66af0. It can be enabled with - "EmptyLineBeforeAccessModifier": "Never"

xgupta avatar Sep 25 '23 12:09 xgupta