[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
Tue Mar 18 14:48:10 PDT 2025
================
@@ -148,6 +160,24 @@ class AnnotatingParser {
}
}
+ const FormatStyle::FunctionDeclarationWithKeywords *
+ isInsideFunctionWithKeywordedParameters(const FormatToken &Token) const {
+ const FormatToken *Previous = &Token;
+ while (auto Prev = Previous->getPreviousNonComment())
+ Previous = Prev;
----------------
HazardyKnusperkeks wrote:
You are searching for the first token in the line, with a loop. But you already have an `AnnotatedLine` (called `Line`) at your disposal, which lets you access the [`First`](https://github.com/llvm/llvm-project/blob/bc646f4b302339717e363efa3e57ec3468d190aa/clang/lib/Format/TokenAnnotator.h#L172) token directly. That `Line` does not correspond to actual lines, but what clang-format thinks of as `UnwrappedLine`. This is independent of indentation and column limit.
For your use case this `Line` should be the whole `Q_PROPERTY` macro.
https://github.com/llvm/llvm-project/pull/131605
More information about the cfe-commits
mailing list