[compiler-rt] [sanitizer] Make CHECKs in bitvector more precise (NFC) (PR #94630)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 6 08:33:48 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: Nikita Popov (nikic)
<details>
<summary>Changes</summary>
These CHECKs are all checking indices, which must be strictly smaller than the size (otherwise they would go out of bounds).
---
Full diff: https://github.com/llvm/llvm-project/pull/94630.diff
1 Files Affected:
- (modified) compiler-rt/lib/sanitizer_common/sanitizer_bitvector.h (+4-4)
``````````diff
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_bitvector.h b/compiler-rt/lib/sanitizer_common/sanitizer_bitvector.h
index 07a59ab11c429..eef1e7e9d9570 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_bitvector.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_bitvector.h
@@ -321,23 +321,23 @@ class TwoLevelBitVector {
};
private:
- void check(uptr idx) const { CHECK_LE(idx, size()); }
+ void check(uptr idx) const { CHECK_LT(idx, size()); }
uptr idx0(uptr idx) const {
uptr res = idx / (BV::kSize * BV::kSize);
- CHECK_LE(res, kLevel1Size);
+ CHECK_LT(res, kLevel1Size);
return res;
}
uptr idx1(uptr idx) const {
uptr res = (idx / BV::kSize) % BV::kSize;
- CHECK_LE(res, BV::kSize);
+ CHECK_LT(res, BV::kSize);
return res;
}
uptr idx2(uptr idx) const {
uptr res = idx % BV::kSize;
- CHECK_LE(res, BV::kSize);
+ CHECK_LT(res, BV::kSize);
return res;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/94630
More information about the llvm-commits
mailing list