<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jun 24, 2020 at 3:02 AM David Chisnall via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">On 23/06/2020 16:51, Adrian McCarthy via llvm-dev wrote:<br>
> Personally, I favor "always use braces" because it helps readability for <br>
> me.  The compiler may be good at flagging misleading indentation, but my <br>
> visual processing system is terrible at it, especially since we use a <br>
> measly two spaces for indentation.  And we grant indentation exceptions <br>
> for--among other things--case labels in switches.<br>
<br>
I remember fixing one bug in LLVM that was caused by not having braces <br>
around an if statement and a modification that didn't notice this.  I <br>
have fixed other bugs in a downstream fork where upstream has done this:<br>
<br>
if (x) {<br>
   something();<br>
   somethingElse();<br>
}<br>
<br>
We've changed it to:<br>
<br>
if (x) {<br>
   something();<br>
   somethingElse();<br>
   ohAndOneMoreThing();<br>
}<br>
<br>
And then upstream has changed it to<br>
<br>
if (x)<br>
   something();<br>
<br>
And, after merge, our code has been:<br>
<br>
if (x)<br>
   something();<br>
   ohAndOneMoreThing();<br></blockquote><div><br></div><div>To be clear this was a merge-conflict that was manually resolved this way right? I don't see git auto-merging this diff.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<br>
In contrast, I have *never*, in any project, had to fix a bug that was <br>
caused by someone inserting redundant braces (or extra brackets) and <br>
someone else failing to understand the code.<br>
<br>
As such, I am strongly in favour of requiring extra braces.  Static <br>
analysers will now often catch the bugs that they prevent but it's <br>
better to make it harder to introduce bugs in the first place than to <br>
depend on tooling to find them later.<br>
<br>
David<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div></div>