[compiler-rt] 982bfec - [NFC][sanitizer] Clang-format sanitizer_flat_map.h
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 10 22:24:08 PDT 2021
Author: Vitaly Buka
Date: 2021-10-10T22:23:49-07:00
New Revision: 982bfec8f0a3e7d6bf7703d17fab1477c53d84dd
URL: https://github.com/llvm/llvm-project/commit/982bfec8f0a3e7d6bf7703d17fab1477c53d84dd
DIFF: https://github.com/llvm/llvm-project/commit/982bfec8f0a3e7d6bf7703d17fab1477c53d84dd.diff
LOG: [NFC][sanitizer] Clang-format sanitizer_flat_map.h
Added:
Modified:
compiler-rt/lib/sanitizer_common/sanitizer_flat_map.h
Removed:
################################################################################
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_flat_map.h b/compiler-rt/lib/sanitizer_common/sanitizer_flat_map.h
index 6940c6607d3c..3040a1f28c2d 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_flat_map.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_flat_map.h
@@ -23,8 +23,8 @@ namespace __sanitizer {
// Call these callbacks on mmap/munmap.
struct NoOpMapUnmapCallback {
- void OnMap(uptr p, uptr size) const { }
- void OnUnmap(uptr p, uptr size) const { }
+ void OnMap(uptr p, uptr size) const {}
+ void OnUnmap(uptr p, uptr size) const {}
};
// Maps integers in rage [0, kSize) to u8 values.
@@ -32,9 +32,7 @@ template <u64 kSize, typename AddressSpaceViewTy = LocalAddressSpaceView>
class FlatMap {
public:
using AddressSpaceView = AddressSpaceViewTy;
- void Init() {
- internal_memset(map_, 0, sizeof(map_));
- }
+ void Init() { internal_memset(map_, 0, sizeof(map_)); }
constexpr uptr size() const { return kSize; }
@@ -43,11 +41,12 @@ class FlatMap {
CHECK_EQ(0U, map_[idx]);
map_[idx] = val;
}
- u8 operator[] (uptr idx) {
+ u8 operator[](uptr idx) {
CHECK_LT(idx, kSize);
// FIXME: CHECK may be too expensive here.
return map_[idx];
}
+
private:
u8 map_[kSize];
};
@@ -71,7 +70,8 @@ class TwoLevelMap {
void TestOnlyUnmap() {
for (uptr i = 0; i < kSize1; i++) {
u8 *p = Get(i);
- if (!p) continue;
+ if (!p)
+ continue;
MapUnmapCallback().OnUnmap(reinterpret_cast<uptr>(p), kSize2);
UnmapOrDie(p, kSize2);
}
@@ -88,10 +88,11 @@ class TwoLevelMap {
map2[idx % kSize2] = val;
}
- u8 operator[] (uptr idx) const {
+ u8 operator[](uptr idx) const {
CHECK_LT(idx, kSize1 * kSize2);
u8 *map2 = Get(idx / kSize2);
- if (!map2) return 0;
+ if (!map2)
+ return 0;
auto value_ptr = AddressSpaceView::Load(&map2[idx % kSize2]);
return *value_ptr;
}
@@ -108,7 +109,7 @@ class TwoLevelMap {
if (!res) {
SpinMutexLock l(&mu_);
if (!(res = Get(idx))) {
- res = (u8*)MmapOrDie(kSize2, "TwoLevelMap");
+ res = (u8 *)MmapOrDie(kSize2, "TwoLevelMap");
MapUnmapCallback().OnMap(reinterpret_cast<uptr>(res), kSize2);
atomic_store(&map1_[idx], reinterpret_cast<uptr>(res),
memory_order_release);
@@ -130,6 +131,6 @@ template <u64 kSize1, u64 kSize2,
using TwoLevelByteMap =
TwoLevelMap<kSize1, kSize2, AddressSpaceViewTy, MapUnmapCallback>;
-}
+} // namespace __sanitizer
-#endif
\ No newline at end of file
+#endif
More information about the llvm-commits
mailing list