<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0cm;
margin-right:0cm;
margin-bottom:0cm;
margin-left:36.0pt;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.gmail-apple-tab-span
{mso-style-name:gmail-apple-tab-span;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:1743478594;
mso-list-type:hybrid;
mso-list-template-ids:1143786702 -1 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;}
@list l0:level1
{mso-level-start-at:0;
mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Symbol;
mso-fareast-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";}
@list l0:level2
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:"Courier New";}
@list l0:level3
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Wingdings;}
@list l0:level4
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Symbol;}
@list l0:level5
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:"Courier New";}
@list l0:level6
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Wingdings;}
@list l0:level7
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Symbol;}
@list l0:level8
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:"Courier New";}
@list l0:level9
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Wingdings;}
ol
{margin-bottom:0cm;}
ul
{margin-bottom:0cm;}
--></style></head><body lang=HU link=blue vlink="#954F72"><div class=WordSection1><p class=MsoNormal><span lang=EN-US>While I am not exactly able to help on the technical details as I’m also new on Clang grounds, if you or anyone else steps forward to implement this, I think it would be nice to early on consider a few more rules, such as:<o:p></o:p></span></p><ul style='margin-top:0cm' type=disc><li class=MsoListParagraph style='margin-left:0cm;mso-list:l0 level1 lfo1'>Aligning the cv-qualifiers together and indent the real type name into a separate column</li><li class=MsoListParagraph style='margin-left:0cm;mso-list:l0 level1 lfo1'>Within some reasonable boundary, align template arguments.</li></ul><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>; Whisperity.</p><p class=MsoNormal><o:p> </o:p></p><div style='mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal style='border:none;padding:0cm'><b>From: </b><a href="mailto:cfe-dev@lists.llvm.org">Marcus Johnson via cfe-dev</a><br><b>Sent: </b>2018. október 10., szerda 0:41<br><b>To: </b><a href="mailto:cfe-dev@lists.llvm.org">cfe-dev</a><br><b>Subject: </b>[cfe-dev] Clang Format: Add option to align types?</p></div><p class=MsoNormal><o:p> </o:p></p><div><div><div><div><div><p class=MsoNormal><span style='font-size:18.0pt'>I'm not sure if this is even the right place to ask, I did a quick search looking for a clang-format specific list but couldn't find one, does anyone know if there even is one?<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'>I'm trying to add an option to Clang-Format that would allow users to align variables in structs/classes and functions based on the width of the type identifier.<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'>Here's a couple examples to better illustrate what I'm talking about:<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'><o:p> </o:p></span></p></div><div><div><div><p class=MsoNormal><span style='font-size:18.0pt'>typedef struct Unaligned_Struct {<o:p></o:p></span></p></div><div><p class=MsoNormal><span class=gmail-apple-tab-span><span style='font-size:18.0pt'> </span></span><span style='font-size:18.0pt'>int wat;<o:p></o:p></span></p></div><div><p class=MsoNormal><span class=gmail-apple-tab-span><span style='font-size:18.0pt'> </span></span><span style='font-size:18.0pt'>uint8_t huh;<o:p></o:p></span></p></div><div><p class=MsoNormal><span class=gmail-apple-tab-span><span style='font-size:18.0pt'> </span></span><span style='font-size:18.0pt'>uint64_t who;<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'>} Unaligned_Struct;<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'>int Unaligned_Average(int A, int B, int num) {<o:p></o:p></span></p></div><div><p class=MsoNormal><span class=gmail-apple-tab-span><span style='font-size:18.0pt'> </span></span><span style='font-size:18.0pt'>int Average = A + B;<o:p></o:p></span></p></div><div><p class=MsoNormal><span class=gmail-apple-tab-span><span style='font-size:18.0pt'> </span></span><span style='font-size:18.0pt'>int32_t Divided = Average / num;<o:p></o:p></span></p></div><div><p class=MsoNormal><span class=gmail-apple-tab-span><span style='font-size:18.0pt'> </span></span><span style='font-size:18.0pt'>return Divided;<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'>}<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'>vs<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'>typedef struct Aligned_Struct {<o:p></o:p></span></p></div><div><p class=MsoNormal><span class=gmail-apple-tab-span><span style='font-size:18.0pt'> </span></span><span style='font-size:18.0pt'>int wat;<o:p></o:p></span></p></div><div><p class=MsoNormal><span class=gmail-apple-tab-span><span style='font-size:18.0pt'> </span></span><span style='font-size:18.0pt'>uint8_t huh;<o:p></o:p></span></p></div><div><p class=MsoNormal><span class=gmail-apple-tab-span><span style='font-size:18.0pt'> </span></span><span style='font-size:18.0pt'>uint64_t who;<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'>} Aligned_Struct;<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'>int Aligned_Average(int A, int B, int num) {<o:p></o:p></span></p></div><div><p class=MsoNormal><span class=gmail-apple-tab-span><span style='font-size:18.0pt'> </span></span><span style='font-size:18.0pt'>int Average = A + B;<o:p></o:p></span></p></div><div><p class=MsoNormal><span class=gmail-apple-tab-span><span style='font-size:18.0pt'> </span></span><span style='font-size:18.0pt'>int32_t Divided = Average / num;<o:p></o:p></span></p></div><div><p class=MsoNormal><span class=gmail-apple-tab-span><span style='font-size:18.0pt'> </span></span><span style='font-size:18.0pt'>return Divided;<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'>}<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'>I'm not sure if the formatting is showing up, so I geuss I'l have to describe it.<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'>The Aligned blocks all of the variables have X number of spaces added between the type and the variable name, so that they're all aligned in a single column.<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'>it makes reading the code a lot easier, I've been doing thi manually with my code for a while, and Clang-Format not having this feature is the biggest reason I don't currently use it.<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'>As for my questions, they are:<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'>How exactly do I do this?<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'>Should I write a new enum (I've been thinking about calling it "AlignTypeDeclarationStyle", but that seems a little clunky, and I'm not sure if it's the best way to describe what exactly is going on)<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'>and how exactly would I hook this into the Clang-Format library?<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:18.0pt'><o:p> </o:p></span></p></div></div></div></div></div></div></div><p class=MsoNormal><span style='font-size:18.0pt'>I've never contributed to the LLVM project before, I've read the documents a few times, and I've tried reading the code, but it's very intertwined and it's hard to drill down as deep as I need.<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>