[clang] [clang-format] add option to control bin-packing keyworded parameters (PR #131605)
Björn Schäpers via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 27 13:07:59 PDT 2025
================
@@ -3146,6 +3146,45 @@ struct FormatStyle {
/// \version 16
IntegerLiteralSeparatorStyle IntegerLiteralSeparator;
+ /// Function-like declaration with keyworded parameters.
+ /// Lists possible keywords for a named macro-like function
+ struct KeywordedFunctionLikeMacro {
+ std::string Name;
+ std::vector<std::string> Keywords;
+
+ bool operator==(const KeywordedFunctionLikeMacro &Other) const {
+ return Name == Other.Name && Keywords == Other.Keywords;
+ }
+ };
+
+ /// Allows to format function-like macros with keyworded parameters according
+ /// to the BinPackParameters setting, treating keywords as parameter
+ /// sepratators.
+ ///
+ /// 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{.yaml}
+ /// 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
+ /// \version 21
+ std::vector<KeywordedFunctionLikeMacro> KeywordedFunctionLikeMacros;
----------------
HazardyKnusperkeks wrote:
K comes after J, please resort here and following.
https://github.com/llvm/llvm-project/pull/131605
More information about the cfe-commits
mailing list