LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 16518 - Add flag to suppress empty line insertion before access modifier.
Summary: Add flag to suppress empty line insertion before access modifier.
Status: NEW
Alias: None
Product: clang
Classification: Unclassified
Component: Formatter (show other bugs)
Version: trunk
Hardware: PC All
: P enhancement
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-01 18:56 PDT by Sean Silva
Modified: 2020-12-27 07:38 PST (History)
4 users (show)

See Also:
Fixed By Commit(s):


Attachments
Patch which adds option to disable forced insertion of empty line before access modifiers. (260.83 KB, patch)
2020-12-21 09:02 PST, Albertas Vyšniauskas
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sean Silva 2013-07-01 18:56:53 PDT
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.
Comment 1 Daniel Jasper 2013-08-28 03:09:25 PDT
Patches are welcome :-).
Comment 2 Albertas Vyšniauskas 2020-12-21 09:02:11 PST
Created attachment 24308 [details]
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).
Comment 3 MyDeveloperDay 2020-12-27 07:38:49 PST
Would you like to submit this patch?

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

If so feel free to add me as a reviewer