[PATCH] D140639: clang: Fix handling of __builtin_elementwise_copysign

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 5 11:38:24 PST 2023


aaron.ballman added inline comments.


================
Comment at: clang/lib/Sema/SemaChecking.cpp:2674
+
+    if (MagnitudeTy.getCanonicalType() != SignTy.getCanonicalType()) {
+      return Diag(Sign.get()->getBeginLoc(),
----------------
erichkeane wrote:
> arsenm wrote:
> > arsenm wrote:
> > > erichkeane wrote:
> > > > arsenm wrote:
> > > > > erichkeane wrote:
> > > > > > curleys not used for single-statement if-statement bodies.
> > > > > It covers 3 lines, it should have braces
> > > > Our standard says 'statments' not 'lines'.  This is a single statement.
> > > > 
> > > > https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements
> > > Also says 'Similarly, braces should be used when a single-statement body is complex enough that it becomes difficult to see where the block containing the following statement began.'
> > > 
> > > Which is any case where it covers multiple lines 
> > Plus I'd go by clang-format does not add braces here
> I don't see the 'difficult to see when the following statement began' bit in this code, particularly with the new line.
> 
> By policy, I don't think we have curleys here.  I'm of the opinion of 'almost always curleys', but our policy.
I think a strict reading of our policy is that the preference is to elide the braces in this case, but FWIW, I'm perfectly fine with leaving the braces in as they (ever-so-slightly) improve the readability of the code given that it spans multiple source lines.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140639/new/

https://reviews.llvm.org/D140639



More information about the cfe-commits mailing list