[clang] [clang-format] add option to bin-pack keyworded parameters (PR #131605)
Björn Schäpers via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 17 12:52:30 PDT 2025
================
@@ -5247,6 +5247,41 @@ struct FormatStyle {
/// \version 20
WrapNamespaceBodyWithEmptyLinesStyle WrapNamespaceBodyWithEmptyLines;
+ struct FunctionDeclarationWithKeywords {
+ std::string Name;
+ std::vector<std::string> Keywords;
+
+ bool operator==(const FunctionDeclarationWithKeywords &Other) const {
+ return Name == Other.Name && Keywords == Other.Keywords;
+ }
+ };
+
+ /// Allows to format function-line macros with keyworded parameters according
+ /// to the BinPackParameters setting, treating keywords as parameter
+ /// sepratators.
+ /// \version 21
+ ///
+ /// Q_PROPERTY is an example of such a macro:
+ /// \code
+ /// Q_PROPERTY(int name READ name WRITE setName NOTIFY nameChanged)
+ /// \endcode
+ ///
+ /// With BinPackParameters set to OnePerLine (or AlwaysOnePerLine) and
+ /// \code
+ /// FunctionDeclarationsWithKeywords:
+ /// - Name: "Q_PROPERTY"
+ /// Keywords: ['READ', 'WRITE', 'MEMBER', 'RESET', 'NOTIFY']
+ /// \endcode
+ /// the line above will be split on these keywords:
+ /// \code
+ /// Q_PROPERTY(
+ /// int name
+ /// READ name
+ /// WRITE setName
+ /// NOTIFY nameChanged)
+ /// \endcode
+ std::vector<FunctionDeclarationWithKeywords> FunctionDeclarationsWithKeywords;
----------------
HazardyKnusperkeks wrote:
This needs to be sorted with the other options.
https://github.com/llvm/llvm-project/pull/131605
More information about the cfe-commits
mailing list