rtrieu marked an inline comment as done.
rtrieu added inline comments.

================
Comment at: test/Sema/parentheses.c:156
+
+  (void)(x ^ b ? 1 : 2);  // no warning, ^ is often used as logical xor
+  (void)(x || b ? 1 : 2);  // no warning, logical operator
----------------
jfb wrote:
> rtrieu wrote:
> > jfb wrote:
> > > I don't understand why `^` is different. What do you mean by "often used 
> > > as a logical xor`?
> > In C++, there's the bitwise operators |, &, and ^.  And there's the logical 
> > operators || and &&.  Since there's no ^^ for a logical-xor, many people 
> > will just use the bitwise-xor ^ instead.  Since this isn't warning on 
> > logical operators, it makes sense to exclude the bitwise-xor that is often 
> > used as logical-xor.
> So code is often buggy when it uses `|` and `&` as diagnosed by this patch, 
> but is rarely buggy when it uses `^`?
That's correct.  From my testing, &&, || and ^ all had low bug finding rates 
and didn't make sense to include into this warning while | and & had a high bug 
finding rate.


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

https://reviews.llvm.org/D66043



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to