<div dir="ltr">I've updated <a href="http://reviews.llvm.org/D14325">http://reviews.llvm.org/D14325</a> with a fix for the parameter declaration alignment issue.<br></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature">--<br>Beren Minor</div></div>
<br><div class="gmail_quote">On Sun, Nov 22, 2015 at 11:43 PM, Graham St Jack via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks for the reply - my response is late too because I have been on leave.<br>
<br>
On 19/11/15 05:21, via cfe-dev wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Message: 4<br>
Date: Wed, 18 Nov 2015 19:53:34 +0100<br>
From: Beren Minor via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>><br>
To: Daniel Jasper <<a href="mailto:djasper@google.com" target="_blank">djasper@google.com</a>><br>
Cc: <a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>, <a href="mailto:graham.stjack@quantum.com" target="_blank">graham.stjack@quantum.com</a><br>
Subject: Re: [cfe-dev] Question about clang-format<br>
Message-ID:<br>
<CAONPvZxsy4=S+Yaa3vxL6Gy983-BsTag4G2UBga9hc8c3CW8=<a href="mailto:Q@mail.gmail.com" target="_blank">Q@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<span class=""><br>
<br>
Sorry for the late answer, the mail was lost in my inbox.<br>
<br>
You're totally right about the pointer and reference attachment rules, but<br>
currently the alignment code doesn't really handle it. I don't think it<br>
would be very hard to implement, but I am wondering what the expected<br>
alignment would be in the case of nested pointer / cv qualifiers. I<br>
personally find such cases troublesome, and that is why I usually attach<br>
the pointers and qualifiers to the type and not to the variable.<br>
<br>
For example, where should the spaces be inserted in the following case:<br>
<br>
const char* const* v1;<br>
float const* v2;<br>
SomeVeryLongType const& v3;<br>
</span></blockquote>
These use cases don't come up in our code base (we only care about the constness of what is pointed/referred to, so the question doesn't arise - but I see the problem.<br>
<br>
For us, what happens with cases like this are more compelling:<br>
<br>
const char *v1, *v2, v3;<br>
<br>
Hence our interest in associating the pointer/reference with the variable rather than the type - although I do admit that we frown on declaring more than one variable per line.<span class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Regarding the function parameter misalignment, this is certainly a bug and<br>
you can file a bugreport about it if you like. I will try to reproduce and<br>
fix it anyway.<br>
</blockquote>
<br></span>
I will leave it in your court, thanks. This is the one that is the real blocker.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
Thanks,<br>
--<br>
Beren Minor<br>
<br>
On Fri, Nov 13, 2015 at 9:52 AM, Daniel Jasper <<a href="mailto:djasper@google.com" target="_blank">djasper@google.com</a>> wrote:<br>
<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
Adding Beren, who has done the development here.<br>
<br>
<br>
On Fri, Nov 13, 2015 at 12:01 AM, Graham St Jack via cfe-dev <<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br>
<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
Hi all,<br>
<br>
I am looking at using clang-format, and like everyone else with a<br>
pre-existing quirky style, there are some things that clang-format doesn't<br>
seem to handle for me.<br>
<br>
Most of the issues are minor - we can just redefine our style, or they<br>
occur rarely enough for it not to matter.<br>
<br>
Some things that stand out as odd though (and make adoption difficult)<br>
are the following blocks of code formatted with this .clang-format file,<br>
using clang-format-3.8 built from trunk source yesterday.<br>
<br>
BasedOnStyle: LLVM<br>
<br>
AlignConsecutiveAssignments: true<br>
AlignConsecutiveDeclarations: true<br>
AllowShortCaseLabelsOnASingleLine: true<br>
AllowShortFunctionsOnASingleLine: Inline<br>
BinPackParameters: false<br>
BinPackArguments: false<br>
BraceWrapping:<br>
IndentBraces: false<br>
AfterNamespace: false<br>
AfterClass: true<br>
AfterControlStatement: true<br>
AfterEnum: true<br>
AfterFunction: true<br>
AfterStruct: true<br>
AfterUnion: true<br>
BeforeCatch: true<br>
BeforeElse: true<br>
BreakBeforeBraces: Custom<br>
ConstructorInitializerIndentWidth: 2<br>
ContinuationIndentWidth: 2<br>
ConstructorInitializerAllOnOneLineOrOnePerLine: true<br>
MaxEmptyLinesToKeep: 1<br>
<br>
----------------------------------------<br>
<br>
int * err = 0;<br>
ino_t_xx dir_inode = 0;<br>
gen_t dir_gen = 0;<br>
<br>
Here, the variables and equal-signs are lined up beautifully, but the<br>
star isn't hard up against 'err' - which I would have expected given the<br>
fact that LLVM sets PointerAlignment to Right. Looking into the<br>
implementation (and doing some experiments), it looks like 'Right' just<br>
means "no need to put a space to the right of a star" - but plenty of<br>
spaces can be inserted to align the variable. Is this intentional, and if<br>
so, is there a plan to add a new option to align pointers/references to the<br>
right (as distinct from not-left like now)?<br>
<br>
Since (regrettably) in C/C++, "pointerness" is associated with the<br>
variable and not the type, having the star hard up against the variable<br>
seems to me to be something that a lot of people would want.<br>
<br>
<br>
----------------------------------------<br>
<br>
static int find_highest_index(ino_t base_inode,<br>
gen_t base_gen,<br>
int fd,<br>
uint32_t *highest_index)<br>
<br>
This looks like a bug - if it aligns some of the parameters, it should<br>
align all of them.<br>
<br>
----------------------------------------<br>
<br>
static int find_highest_index(<br>
ino_t base_inode, gen_t base_gen, int fd, uint32_t *highest_index, bool<br>
dummy)<br>
<br>
This looks like a bug too - I added an extra parameter with a short type<br>
to demonstrate that the first and last parameters aren't aligned, but it<br>
put them all on one line. If there is an extra configuration parameter that<br>
would prevent this, please let me know.<br>
<br>
----------------------------------------<br>
<br>
static int find_highest_index(ino_t base_inode,<br>
int fd,<br>
uint32_t *highest_index,<br>
bool dummy)<br>
<br>
Here is the example that shows the first and last parameter aren't<br>
aligned, but the others are.<br>
<br>
<br>
Thanks<br>
<br>
--<br>
Graham St Jack | Software Engineer | Quantum<br>
<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
</div></div><a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_cfe-2Ddev&d=CwIGaQ&c=8S5idjlO_n28Ko3lg6lskTMwneSC-WqZ5EBTEEvDlkg&r=yTQSm-kpxQWFmaw_dZw3NDIbiHmjByJUaCZAObR4cjk&m=txXwxkJVYrSF9OKwEB6ccTSxCsEMnoTxVYXq8gtPE-U&s=YcA6gd67WO2JnSODQdhhCsw1x2uZE7WalB25sZMMRr0&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_cfe-2Ddev&d=CwIGaQ&c=8S5idjlO_n28Ko3lg6lskTMwneSC-WqZ5EBTEEvDlkg&r=yTQSm-kpxQWFmaw_dZw3NDIbiHmjByJUaCZAObR4cjk&m=txXwxkJVYrSF9OKwEB6ccTSxCsEMnoTxVYXq8gtPE-U&s=YcA6gd67WO2JnSODQdhhCsw1x2uZE7WalB25sZMMRr0&e=</a><br>
<br>
</blockquote>
<br>
</blockquote>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_pipermail_cfe-2Ddev_attachments_20151118_545bc757_attachment.html&d=CwIGaQ&c=8S5idjlO_n28Ko3lg6lskTMwneSC-WqZ5EBTEEvDlkg&r=yTQSm-kpxQWFmaw_dZw3NDIbiHmjByJUaCZAObR4cjk&m=txXwxkJVYrSF9OKwEB6ccTSxCsEMnoTxVYXq8gtPE-U&s=ZTepWq0tjqTSgDGjP2RD5sf5MP_xviz8zdwI9db_jyI&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_pipermail_cfe-2Ddev_attachments_20151118_545bc757_attachment.html&d=CwIGaQ&c=8S5idjlO_n28Ko3lg6lskTMwneSC-WqZ5EBTEEvDlkg&r=yTQSm-kpxQWFmaw_dZw3NDIbiHmjByJUaCZAObR4cjk&m=txXwxkJVYrSF9OKwEB6ccTSxCsEMnoTxVYXq8gtPE-U&s=ZTepWq0tjqTSgDGjP2RD5sf5MP_xviz8zdwI9db_jyI&e=</a> ><br>
<br>
------------------------------<br>
<br>
Subject: Digest Footer<span class=""><br>
<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
</span><a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_cfe-2Ddev&d=CwIGaQ&c=8S5idjlO_n28Ko3lg6lskTMwneSC-WqZ5EBTEEvDlkg&r=yTQSm-kpxQWFmaw_dZw3NDIbiHmjByJUaCZAObR4cjk&m=txXwxkJVYrSF9OKwEB6ccTSxCsEMnoTxVYXq8gtPE-U&s=YcA6gd67WO2JnSODQdhhCsw1x2uZE7WalB25sZMMRr0&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_cfe-2Ddev&d=CwIGaQ&c=8S5idjlO_n28Ko3lg6lskTMwneSC-WqZ5EBTEEvDlkg&r=yTQSm-kpxQWFmaw_dZw3NDIbiHmjByJUaCZAObR4cjk&m=txXwxkJVYrSF9OKwEB6ccTSxCsEMnoTxVYXq8gtPE-U&s=YcA6gd67WO2JnSODQdhhCsw1x2uZE7WalB25sZMMRr0&e=</a><br>
<br>
<br>
------------------------------<br>
<br>
End of cfe-dev Digest, Vol 101, Issue 110<br>
*****************************************<span class="HOEnZb"><font color="#888888"><br>
</font></span></blockquote><span class="HOEnZb"><font color="#888888">
<br>
<br>
-- <br>
Graham St Jack | Software Engineer | Quantum | Office: 8304 8919 | Mobile: <a href="tel:0417%20281%20693" value="+33417281693" target="_blank">0417 281 693</a></font></span><div class="HOEnZb"><div class="h5"><br>
<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</div></div></blockquote></div><br></div>