Fix Wbitwise-instead-of-logical warnings

`a && b` only evaluates b if a is true. `a & b` always evaluates
both a and b. If a and b are of type bool, `&&` is usually what you
want, so clang now warns on `&` where both arguments are of type bool.

This warning fires twice in v8.

1. In branch-elimination.cc, we have the rare case where we _want_
   to evaluate both branches so that both reduced_ and node_conditions_
   are always updated. To make this more obvious, reorder the code a
   bit. (The warning can also be suppressed by casting one of the two
   expressions to int, but the reordering seems clearer.)

2. The other case is an actual (inconsequential) typo, so use || here.

Bug: chromium:1255745
Change-Id: I62ba45451ee2642265574d28c646d85f5a18670b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3212891
Auto-Submit: Nico Weber <thakis@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77314}
This commit is contained in:
Nico Weber 2021-10-08 11:07:36 -04:00 committed by V8 LUCI CQ
parent 2a0bc36dec
commit bc4ea5e0fc
2 changed files with 4 additions and 2 deletions

View File

@ -415,7 +415,9 @@ Reduction BranchElimination::UpdateConditions(
Node* node, ControlPathConditions conditions) {
// Only signal that the node has Changed if the condition information has
// changed.
if (reduced_.Set(node, true) | node_conditions_.Set(node, conditions)) {
bool reduced_changed = reduced_.Set(node, true);
bool node_conditions_changed = node_conditions_.Set(node, conditions);
if (reduced_changed || node_conditions_changed) {
return Changed(node);
}
return NoChange();

View File

@ -1446,7 +1446,7 @@ void FeedbackNexus::ResetTypeProfile() {
FeedbackIterator::FeedbackIterator(const FeedbackNexus* nexus)
: done_(false), index_(-1), state_(kOther) {
DCHECK(IsLoadICKind(nexus->kind()) ||
IsStoreICKind(nexus->kind()) | IsKeyedLoadICKind(nexus->kind()) ||
IsStoreICKind(nexus->kind()) || IsKeyedLoadICKind(nexus->kind()) ||
IsKeyedStoreICKind(nexus->kind()) || IsStoreOwnICKind(nexus->kind()) ||
IsStoreDataPropertyInLiteralKind(nexus->kind()) ||
IsStoreInArrayLiteralICKind(nexus->kind()) ||