Created attachment 21949 [details] Files to reproduce bug #Description Inconsistent behavior regarding line break before access modifier. If a newline exists it gets removed. If no newline exists it gets added. Similar but not quite the same: https://bugs.llvm.org/show_bug.cgi?id=16518 #How to reproduce: clang-format --style=file example.hpp > example_after.hpp ##.clang-format MaxEmptyLinesToKeep: 0 ##example.hpp class a { public: void b(); public: // newline gets inserted void c(); public: // newline gets removed void d(); } ##example_after.hpp class a { public: void b(); public: // newline gets inserted void c(); public: // newline gets removed void d(); }
OS: Win10 Clang version: 8.0
Created attachment 24703 [details] Possible bugfix Reproduces on OS: Fedora Clang version: 11.0 and 12.0 The problem is that, Newlines is set to 1 because of the setting `MaxEmptyLinesToKeep`. The checks in the logic are based on `RootToken.NewlinesBefore` which is 2 and therefore Newlines is not changes. The checks need to be changed to the actual value of Newlines. I will submit a merge request for the change.
Created a merge request for the fix. https://reviews.llvm.org/D99503
Fixed via merge request https://reviews.llvm.org/D99503.