From f89d7f8e7b6133471d2ff5673857865fba22ea36 Mon Sep 17 00:00:00 2001 From: Richard Barnes Date: Wed, 4 Jan 2023 19:49:34 -0800 Subject: [PATCH] Fix -Wbitwise-instead-of-logical in 5 files starting w/ fbpcs/emp_games/pcf2_attribution/AttributionRule_impl.h Summary: With LLVM-15, `&&` and `||` are required for boolean operands, rather than `&` and `|` which can be confused for bitwise operations. Fixing such ambiguity helps makes our code more readable. - If you approve of this diff, please use the "Accept & Ship" button :-) Reviewed By: meyering Differential Revision: D42347735 fbshipit-source-id: 23b5dc52fb4e2014a6f89d90c710b194c21971ec --- hphp/runtime/base/runtime-option.cpp | 14 +++++++------- hphp/runtime/ext/hsl/hsl_locale_libc_ops.cpp | 10 +++++----- hphp/util/bloom-filter.h | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/hphp/runtime/base/runtime-option.cpp b/hphp/runtime/base/runtime-option.cpp index fed364ca7d52ba..80947d207ae1bf 100644 --- a/hphp/runtime/base/runtime-option.cpp +++ b/hphp/runtime/base/runtime-option.cpp @@ -1417,11 +1417,11 @@ static std::vector getTierOverwrites(IniSetting::Map& ini, // evaluated; otherwise with multiple patterns, if an earlier // one fails to match, the later one is reported as unused. return - Config::matchHdfPattern(hostname, ini, hdf, "machine") & - Config::matchHdfPattern(tier, ini, hdf, "tier") & - Config::matchHdfPattern(task, ini, hdf, "task") & - Config::matchHdfPattern(tiers, ini, hdf, "tiers", "m") & - Config::matchHdfPattern(tags, ini, hdf, "tags", "m") & + Config::matchHdfPattern(hostname, ini, hdf, "machine") && + Config::matchHdfPattern(tier, ini, hdf, "tier") && + Config::matchHdfPattern(task, ini, hdf, "task") && + Config::matchHdfPattern(tiers, ini, hdf, "tiers", "m") && + Config::matchHdfPattern(tags, ini, hdf, "tags", "m") && Config::matchHdfPattern(cpu, ini, hdf, "cpu"); }; @@ -1442,8 +1442,8 @@ static std::vector getTierOverwrites(IniSetting::Map& ini, // Check the patterns using "&" rather than "&&" so they all get // evaluated; otherwise with multiple patterns, if an earlier // one fails to match, the later one is reported as unused. - if (checkPatterns(hdf) & - (!hdf.exists("exclude") || !checkPatterns(hdf["exclude"])) & + if (checkPatterns(hdf) && + (!hdf.exists("exclude") || !checkPatterns(hdf["exclude"])) && matchShard(enableShards, hostname, ini, hdf, messages)) { messages.emplace_back(folly::sformat( "Matched tier: {}", hdf.getName())); diff --git a/hphp/runtime/ext/hsl/hsl_locale_libc_ops.cpp b/hphp/runtime/ext/hsl/hsl_locale_libc_ops.cpp index e4d60c4aaa0555..eaf5b08f983179 100644 --- a/hphp/runtime/ext/hsl/hsl_locale_libc_ops.cpp +++ b/hphp/runtime/ext/hsl/hsl_locale_libc_ops.cpp @@ -120,7 +120,7 @@ int64_t HSLLocaleLibcOps::strcasecmp(const String& a, const String& b) const { } bool HSLLocaleLibcOps::starts_with(const String& str, const String& prefix) const { - assertx(!str.isNull() & !prefix.isNull()); + assertx(!str.isNull() && !prefix.isNull()); if (str.size() < prefix.size()) { return false; } @@ -128,7 +128,7 @@ bool HSLLocaleLibcOps::starts_with(const String& str, const String& prefix) cons } bool HSLLocaleLibcOps::starts_with_ci(const String& str, const String& prefix) const { - assertx(!str.isNull() & !prefix.isNull()); + assertx(!str.isNull() && !prefix.isNull()); if (str.size() < prefix.size()) { return false; } @@ -136,7 +136,7 @@ bool HSLLocaleLibcOps::starts_with_ci(const String& str, const String& prefix) c } bool HSLLocaleLibcOps::ends_with(const String& str, const String& suffix) const { - assertx(!str.isNull() & !suffix.isNull()); + assertx(!str.isNull() && !suffix.isNull()); if (str.size() < suffix.size()) { return false; } @@ -145,7 +145,7 @@ bool HSLLocaleLibcOps::ends_with(const String& str, const String& suffix) const } bool HSLLocaleLibcOps::ends_with_ci(const String& str, const String& suffix) const { - assertx(!str.isNull() & !suffix.isNull()); + assertx(!str.isNull() && !suffix.isNull()); if (str.size() < suffix.size()) { return false; } @@ -331,7 +331,7 @@ String HSLLocaleLibcOps::replace_every_nonrecursive_ci(const String& haystack, haystack, replacements, /* to_t = */ id, - /* from_t = */ id, + /* from_t = */ id, /* normalize = */ [](String* s) {}, [](String* s) { *s = HHVM_FN(strtolower)(*s); diff --git a/hphp/util/bloom-filter.h b/hphp/util/bloom-filter.h index a31a3437a2e680..5df9bb57011d4b 100644 --- a/hphp/util/bloom-filter.h +++ b/hphp/util/bloom-filter.h @@ -33,7 +33,7 @@ template struct BloomFilter { } bool test(T x) const { auto h = hash_int64(intptr_t(x)); - return bits_.test(h1(h)) & bits_.test(h2(h)); + return bits_.test(h1(h)) && bits_.test(h2(h)); } void clear() { bits_.reset();