From 982bfec8f0a3e7d6bf7703d17fab1477c53d84dd Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Sun, 10 Oct 2021 21:57:12 -0700 Subject: [PATCH] [NFC][sanitizer] Clang-format sanitizer_flat_map.h --- .../lib/sanitizer_common/sanitizer_flat_map.h | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) 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 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(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(res), kSize2); atomic_store(&map1_[idx], reinterpret_cast(res), memory_order_release); @@ -130,6 +131,6 @@ template ; -} +} // namespace __sanitizer -#endif \ No newline at end of file +#endif -- 2.34.1