<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Mar 22, 2015 at 12:39 PM, Richard <span dir="ltr"><<a href="mailto:legalize@xmission.com" target="_blank">legalize@xmission.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi rafael, alexfh,<br>
<br>
Simplify boolean expressions using `true` and `false` with `clang-tidy`<br>
<br>
<a href="http://reviews.llvm.org/D8518" target="_blank">http://reviews.llvm.org/D8518</a><br>
<br>
Files:<br>
tools/llvm-nm/llvm-nm.cpp<br>
<br>
Index: tools/llvm-nm/llvm-nm.cpp<br>
===================================================================<br>
--- tools/llvm-nm/llvm-nm.cpp<br>
+++ tools/llvm-nm/llvm-nm.cpp<br>
@@ -190,19 +190,15 @@<br>
return true;<br>
else if (A.Address == B.Address && A.Name < B.Name)<br>
return true;<br>
- else if (A.Address == B.Address && A.Name == B.Name && A.Size < B.Size)<br>
- return true;<br>
else<br>
- return false;<br>
+ return A.Address == B.Address && A.Name == B.Name && A.Size < B.Size;<br></blockquote><div><br>The asymmetry here (& in other cases in this patch) isn't ideal and this code already violates the LLVM else-after-return coding convention.<br><br>If we changed the code to:<br><br>if (x)<br> return true;<br>return false;<br><br>would it still trigger the cleanup check you're using? I don't mind changing that last one to 'return x;' if that's substantially easier/better than suppressing the check in such cases. <br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
} else {<br>
if (A.Address > B.Address)<br>
return true;<br>
else if (A.Address == B.Address && A.Name > B.Name)<br>
return true;<br>
- else if (A.Address == B.Address && A.Name == B.Name && A.Size > B.Size)<br>
- return true;<br>
else<br>
- return false;<br>
+ return A.Address == B.Address && A.Name == B.Name && A.Size > B.Size;<br>
}<br>
}<br>
<br>
@@ -212,19 +208,15 @@<br>
return true;<br>
else if (A.Size == B.Size && A.Name < B.Name)<br>
return true;<br>
- else if (A.Size == B.Size && A.Name == B.Name && A.Address < B.Address)<br>
- return true;<br>
else<br>
- return false;<br>
+ return A.Size == B.Size && A.Name == B.Name && A.Address < B.Address;<br>
} else {<br>
if (A.Size > B.Size)<br>
return true;<br>
else if (A.Size == B.Size && A.Name > B.Name)<br>
return true;<br>
- else if (A.Size == B.Size && A.Name == B.Name && A.Address > B.Address)<br>
- return true;<br>
else<br>
- return false;<br>
+ return A.Size == B.Size && A.Name == B.Name && A.Address > B.Address;<br>
}<br>
}<br>
<br>
@@ -234,19 +226,15 @@<br>
return true;<br>
else if (A.Name == B.Name && A.Size < B.Size)<br>
return true;<br>
- else if (A.Name == B.Name && A.Size == B.Size && A.Address < B.Address)<br>
- return true;<br>
else<br>
- return false;<br>
+ return A.Name == B.Name && A.Size == B.Size && A.Address < B.Address;<br>
} else {<br>
if (A.Name > B.Name)<br>
return true;<br>
else if (A.Name == B.Name && A.Size > B.Size)<br>
return true;<br>
- else if (A.Name == B.Name && A.Size == B.Size && A.Address > B.Address)<br>
- return true;<br>
else<br>
- return false;<br>
+ return A.Name == B.Name && A.Size == B.Size && A.Address > B.Address;<br>
}<br>
}<br>
<br>
@@ -263,10 +251,8 @@<br>
return true;<br>
else if (isa<ELF32BEObjectFile>(Obj))<br>
return false;<br>
- else if (isa<ELF64BEObjectFile>(Obj))<br>
- return true;<br>
else<br>
- return false;<br>
+ return isa<ELF64BEObjectFile>(Obj);<br>
}<br>
<br>
static StringRef CurrentFilename;<br>
<br>
EMAIL PREFERENCES<br>
<a href="http://reviews.llvm.org/settings/panel/emailpreferences/" target="_blank">http://reviews.llvm.org/settings/panel/emailpreferences/</a><br>
<br>_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div><br></div></div>