[clang] a0324e9 - SanitizerMask::bitPosToMask - fix operator precedence warnings. NFCI.
Simon Pilgrim via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 4 07:13:39 PST 2019
Author: Simon Pilgrim
Date: 2019-11-04T15:12:01Z
New Revision: a0324e911374441151903ed0d828e0fc1994c167
URL: https://github.com/llvm/llvm-project/commit/a0324e911374441151903ed0d828e0fc1994c167
DIFF: https://github.com/llvm/llvm-project/commit/a0324e911374441151903ed0d828e0fc1994c167.diff
LOG: SanitizerMask::bitPosToMask - fix operator precedence warnings. NFCI.
Fix static analyzer operator precedence warnings with suitable bracketing. Pull out the mask generation code so clang-format doesn't make such a mess of it.
Added:
Modified:
clang/include/clang/Basic/Sanitizers.h
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/Sanitizers.h b/clang/include/clang/Basic/Sanitizers.h
index 5961abf2aa19..c6b0446cea4f 100644
--- a/clang/include/clang/Basic/Sanitizers.h
+++ b/clang/include/clang/Basic/Sanitizers.h
@@ -52,10 +52,11 @@ class SanitizerMask {
/// Create a mask with a bit enabled at position Pos.
static constexpr SanitizerMask bitPosToMask(const unsigned Pos) {
- return SanitizerMask((Pos < kNumBitElem) ? 1ULL << Pos % kNumBitElem : 0,
- (Pos >= kNumBitElem && Pos < kNumBitElem * 2)
- ? 1ULL << Pos % kNumBitElem
- : 0);
+ uint64_t mask1 = (Pos < kNumBitElem) ? 1ULL << (Pos % kNumBitElem) : 0;
+ uint64_t mask2 = (Pos >= kNumBitElem && Pos < (kNumBitElem * 2))
+ ? 1ULL << (Pos % kNumBitElem)
+ : 0;
+ return SanitizerMask(mask1, mask2);
}
unsigned countPopulation() const {
More information about the cfe-commits
mailing list