[all-commits] [llvm/llvm-project] 27e4ef: [clang-format] Upgrade ShortFunctionStyle to a str...
Ivan via All-commits
all-commits at lists.llvm.org
Sat Mar 14 23:01:29 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 27e4ef689a3aa93173dbd212de8aa5a2b5f65402
https://github.com/llvm/llvm-project/commit/27e4ef689a3aa93173dbd212de8aa5a2b5f65402
Author: Ivan <482199+irymarchyk at users.noreply.github.com>
Date: 2026-03-14 (Sat, 14 Mar 2026)
Changed paths:
M clang/docs/ClangFormatStyleOptions.rst
M clang/include/clang/Format/Format.h
M clang/lib/Format/Format.cpp
M clang/lib/Format/TokenAnnotator.cpp
M clang/lib/Format/UnwrappedLineFormatter.cpp
M clang/unittests/Format/ConfigParseTest.cpp
M clang/unittests/Format/DefinitionBlockSeparatorTest.cpp
M clang/unittests/Format/FormatTest.cpp
M clang/unittests/Format/FormatTestCSharp.cpp
M clang/unittests/Format/FormatTestJS.cpp
M clang/unittests/Format/FormatTestJava.cpp
Log Message:
-----------
[clang-format] Upgrade ShortFunctionStyle to a struct (#134337)
The current clang-format configuration
option AllowShortFunctionsOnASingleLine uses a single enum
(ShortFunctionStyle) to control when short function definitions can be
merged onto a single line. This enum provides predefined combinations of
conditions
(e.g., None, Empty only, Inline only, Inline including Empty, All).
This approach has limitations:
1. **Lack of Granularity:** Users cannot specify arbitrary combinations
of conditions. For example, a user might want to allow merging
for both empty functions and short top-level functions, but not for
short functions defined within classes. This is not possible with the
current enum options except by choosing All, which might merge more than
desired.
2. **Inflexibility:** Adding new conditions for merging (e.g.,
distinguishing between member functions and constructors, handling
lambdas specifically) would require adding many new combined enum
values, leading to a combinatorial explosion and making the
configuration complex.
3. **Implicit Behavior:** Some options imply others
(e.g., Inline implies Empty), which might not always be intuitive or
desired.
The goal is to replace this single-choice enum with a more flexible
mechanism allowing users to specify a set of conditions that must be met
for a short function to be merged onto a single line.
---------
Co-authored-by: owenca <owenpiano at gmail.com>
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list