<div dir="ltr"><div><div><div><div><div><div><div><div>This Q&A asks about using clang-format to support table-like code:<br><br><a href="http://stackoverflow.com/questions/38022831/how-to-make-clang-format-respect-table-like-code-formatting">http://stackoverflow.com/questions/38022831/how-to-make-clang-format-respect-table-like-code-formatting</a><br><br></div><div>Motivating examples for this sort of thing include GUI construction code (e.g., this Qt sample code: <a href="http://doc.qt.io/qt-5/qtwidgets-widgets-groupbox-example.html#window-class-implementation">http://doc.qt.io/qt-5/qtwidgets-widgets-groupbox-example.html#window-class-implementation</a> ).<br></div><div><br></div>The two cases mentioned in the Q&A could be slightly expanded to:<br></div><div><br></div>1. Braced initializers (including C++11 initializer lists).<br></div>2. Function calls<br></div><br></div>Each could include:<br><br>a. Rows and columns within a single statement (shown in Q&A)<br></div><br>b. Rows in different statements with columns following the same pattern for each row (shown in the Q&A with Create() functions -- same function call, same number of params, etc.).<br></div><br>c. Nested tables,e.g., <br><br></div>  S s = {<br>    { { "Dubs", abc,    123 },<br>      { "X",    n,      m   },<br>      { "YZ",   ij / q, kl  } },<br><br>    { { "Dubs", abc,    123 },<br>      { "X",    n,      m   },<br>      { "YZ",   ij / q, kl  } },<br>  };<br><div><br></div><div>vs. (perhaps depending on max line length or user option)<br></div><div><br>  S s = {<br>    { { "Dubs", abc,    123 }, { "X",    n,      m   }, { "YZ",   ij / q, kl  } },<br>    { { "X",    n,      m   }, { "YZ",   ij / q, kl  }, { "Dubs", abc,    123 }  },<br>  };<br><div><br></div><div>Similar nesting could be done with function calls within function call params.<br></div><div><br></div>d. Rows and columns following a looser pattern (e.g., different function names, different number of params, optionally keeping return values):<br><br></div>  w  = CreateDubs( "Dubs", abc,    123 );<br>  x  = CreateEx(   "X",    n           ); // Two params!<br>  CreateWhyZed(    "YZ",   ij / q, kl  ); // Ignore return value<br><br><div><div><div>My question is, how hard would it be to modify LibFormat to support some or all of these cases? <br><br>I'm an experienced developer, but I've not done LLVM development before. I'm potentially interested in working on it and submitting a patch, but I thought I would ask here first in case you can tell me that it would be an exercise in futility or would be unlikely to be accepted as a feature. Would it have to support all of these cases to be accepted?<br><br></div><div>Cheers!<br></div><div><br></div><div>M<br></div></div></div></div>