This fixes bug 25192.
See https://llvm.org/bugs/show_bug.cgi?id=25192.
Details
Diff Detail
Event Timeline
lib/Format/UnwrappedLineFormatter.cpp | ||
---|---|---|
193 | From a first look, this doesn't make sense. We specifically check that the next line is a closing brace to ensure that this is an empty function. Now, this seems to work with the existing tests, but because of very intricate reasons:
Instead, pull out an additional variable: bool EmptyFunction = (Style.BraceWrapping.AfterFunction ? I[2] : I[1])->First->is(tok::r_brace); and then use that. Please also add a test showing that non-empty functions do not get merged. | |
unittests/Format/FormatTest.cpp | ||
6523 | Just extend PullInlineFunctionDefinitionsIntoSingleLine instead. |
- AllowShortFunctionsOnASingleLine: true didn't work with BreakBeforeBraces: Linux/Allman.
- Add test checking that non-empty functions in styles with BraceWrapping.AfterFunction = true don't get merged into one line. Fix the merge condition.
Applied comments.
lib/Format/UnwrappedLineFormatter.cpp | ||
---|---|---|
190 | IMO, (I + 2 != E) is a bit awkward yet necessary here, but I don't see a better way to check if we have more than two tokens. |
IMO, (I + 2 != E) is a bit awkward yet necessary here, but I don't see a better way to check if we have more than two tokens.