<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Jun 21, 2017 at 4:15 AM, Daniel Jasper 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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I don't think there is a useful way of doing this. If you want developers to get the same layout, they have to use the same version of the tool. You can assume that every single version change leads to a different layout somewhere, or else we wouldn't be making the change. Often these changes affect a rare corner case of the syntax, but in a reasonably large codebase, they are still always triggered. Is it impractical to ship the same version of clang-format to all contributors? clang-format is reasonably small and you could just check in the version that the CI uses into your repository for everyone to use. That also enables you to update that version together with the formatting changes that it entails.<div><br></div><div>However, I would also argue that a format check on CI builds is not useful. The polly project inside LLVM does that and it seems rather painful. Instead, verify that the changed version of a file adheres to what clang-format produces at the time the change is submitted. This is what Chromium and other large projects do and has proven to be effective. Then, even if the versions differ a bit, there won't be unnecessary churn as a formatting change is always bundled with an actually code change.</div></div></blockquote><div><br></div><div>To add some more detail: We run `git diff -U0` to get a diff of the current branch with trunk and then pipe that into clang-format-diff.py -i from the LLVM tree, which then formats only the bits of each file that have been modified.</div><div><br></div><div>In a presubmit, we do the same thing (without -i) and check that clang-format-diff.py produces no output.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-HOEnZb"><div class="gmail-h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 20, 2017 at 9:37 PM, Jonathan Müller 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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-m_-2599986438816115872HOEnZb"><div class="gmail-m_-2599986438816115872h5">On 20.06.2017 21:20, Pim Schellart via cfe-dev wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Dear Clang Developers,<br>
<br>
this may not be the right place to ask this question so please redirect me if I’m mistaken.<br>
<br>
We are using clang-format for automatic code layout within our project.<br>
A problem we are facing is that developers have different versions of clang-format installed.<br>
Even with identical style configuration this results in different output, leading to unnecessary diffs.<br>
<br>
While this can be fixed by mandating a specific clang-format version, this may not be practical.<br>
It would be helpful if one could pin a particular layout behavior in a forwards compatible way.<br>
<br>
If that is not possible, it would be nice to know when version changes result in layout changes.<br>
E.g. should we mandate version 5.0.0 or is 5.0.x or even 5.x enough?<br>
<br>
Thanks in advance.<br>
<br>
Kind regards,<br>
<br>
Pim Schellart<br>
______________________________<wbr>_________________<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/<wbr>mailman/listinfo/cfe-dev</a><br>
<br>
</blockquote>
<br></div></div>
I have the issue as well, I used to have a clang-format checker on my CI builds, but this was annoying as my clang version updates more often than the one on CI, leading to inconsistencies and thus failed builds.<div class="gmail-m_-2599986438816115872HOEnZb"><div class="gmail-m_-2599986438816115872h5"><br>
______________________________<wbr>_________________<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/<wbr>mailman/listinfo/cfe-dev</a><br>
</div></div></blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">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/<wbr>mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div>