[PATCH] [ClangFormat] Add ConstructorInitializerOffset to control initializer list indentation

Klemens Baum klemensbaum at gmail.com
Tue Aug 13 01:48:08 PDT 2013


  For the Phrabricator issue: I tried uploading a full-context diff [here](http://llvm-reviews.chandlerc.com/differential/diff/3416/). If you expand FormatTest.cpp, you'll see that it gets truncated at line 5782.


================
Comment at: ../tools/clang/lib/Format/Format.cpp:656
@@ +655,3 @@
+      } else if (Current.Type == TT_CtorInitializerComma) {
+        assert(Style.BreakConstructorInitializersBeforeComma);
+        State.Column = State.Stack.back().Indent;
----------------
Daniel Jasper wrote:
> Klemens Baum wrote:
> > Daniel Jasper wrote:
> > > Do not assert!!! This is easy to force by user input, e.g. by:
> > > 
> > >   Constructor::Constructor() : a(a) // a
> > >   , b(b) {}
> > > 
> > > It's fine not to format perfectly in that case, but we shouldn't crash.
> > Since this whole block is within the `if (Newline)`, `Current` refers to the first token to emit on that line. Unless we are using the BreakConstructorInitializersBeforeComma style, it cannot be an initializer list comma token. So I don't think this can be triggered by user input.
> Well, I have given you the user input that triggers it.
Oh, right. I didn't realize that comment was there.


http://llvm-reviews.chandlerc.com/D1360



More information about the cfe-commits mailing list