[cfe-dev] clang-format debugging help: bin-packing of argument subexpressions

Jacob Bandes-Storch via cfe-dev cfe-dev at lists.llvm.org
Sun Apr 23 12:50:38 PDT 2017


Hi,
Is there anyone familiar with the clang-format implementation who could
point me in the right direction for fixing a limitation?

I have noticed that setting "BinPackArguments: false" also disables
bin-packing of expressions *within* call arguments, after the first filled
line. For instance:

     someFunctionCall(
           argumentOne,
           argumentTwo,
           1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14
                 + 15
                 + 16
                 + 17
                 + 18
                 + 19
                 + 20);

I could see enabling/disabling bin-packing for expressions being a valuable
feature, perhaps as a separate BinPackExpressions (separate from
-Parameters and -Arguments), but as it is today this just seems like a bug.

The implementation of ContinuationIndenter::addTokenOnCurrentLine,
addTokenOnNewLine,
canBreak, mustBreak, etc. are a bit hairy for a first-time reader, so I'm
not really sure what's going wrong yet. It seems mustBreak is returning
true from "Current.is(TT_BinaryOperator) && Current.CanBreakBefore &&
State.Stack.back().BreakBeforeParameter
<https://github.com/llvm-mirror/clang/blob/master/lib/Format/ContinuationIndenter.cpp#L248-L251>".
Does anyone have insight into why this condition exists?
BreakBeforeParameter doesn't seem relevant to this situation.

Thanks :-)
Jacob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170423/f457b3b4/attachment.html>


More information about the cfe-dev mailing list