[PATCH] D30487: ClangFormat - Add option to break before inheritance separation operator in class declaration

Andi via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 3 04:24:09 PST 2017


Abpostelnicu added inline comments.


================
Comment at: lib/Format/TokenAnnotator.cpp:2400
+// Returns 'true' if there is an TT_InheritanceComma in the current token list.
+static bool hasMultipleInheritance(const FormatToken &Tok) {
+  for (const FormatToken* nextTok = Tok.Next; nextTok; nextTok = nextTok->Next)
----------------
djasper wrote:
> Abpostelnicu wrote:
> > djasper wrote:
> > > I don't think you need this. If you set MustBreakBefore to true for the InheritanceCommas and set NoLineBreak to true when adding the InheritanceColon on the same line, then clang-format will already do the right thing.
> > > 
> > > Fundamentally, this seems to be identical to how we wrap constructor initializer lists in Mozilla style. So I think we should also implement this the same way (if not even reusing the same implementation).
> > Now that i've seen the behaviour of NoLineBreak thanks for pointing it out to me, but still correct me if i'm wrong but shouldn't i use: ``NoLineBreakInOperand``. 
> > My guess is if i use NoLineBreak, than breaking on the current line where we would have : or , would be prohibited.
> Yes, that would be prohibited and that is intended. Remember that I'd set this after placing the colon on the same line (and I should have written explicitly) as the class name. After that, there must not be any further line breaks.
> 
> But again, I think we should just have the exact same behavior and implementation as for constructor initializer lists.
Yes we should have the exact behaviour like the constructor initialisation list, but that one is also controlled by this flag: ``BreakConstructorInitializersBeforeComma``, that on our coding style is set to true.
But still the actual behaviour of initialiser list still breaks before ``'`` for only one item.


Repository:
  rL LLVM

https://reviews.llvm.org/D30487





More information about the cfe-commits mailing list