[clang] [clang-format][NFC] Add tests for short function merging (PR #234615)
Jesse Rosenstock via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 30 06:24:04 PDT 2026
================
@@ -15233,6 +15233,65 @@ TEST_F(FormatTest, PullTrivialFunctionDefinitionsIntoSingleLine) {
"}");
}
+// Even when both short functions and short if statements are enabled, a
+// function body consisting of `if (x) return y;` is parsed as two unwrapped
+// lines (`if (x)` and `return y;`), so `tryMergeSimpleBlock` does not merge
+// the function onto a single line.
+//
+// FIXME: The desired output is `void f() { if (x) return y; }`.
----------------
jmr wrote:
Filed the remaining cases as issues instead:
* #237208: unbraced `if` in a short function isn't merged
* #237211: short functions whose body contains braces (lambda, braced `if`) aren't merged
https://github.com/llvm/llvm-project/pull/234615
More information about the cfe-commits
mailing list