[compiler-rt] 9ccb602 - [NFC][sanitizer] Add a few consts

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 10 23:00:05 PDT 2021


Author: Vitaly Buka
Date: 2021-10-10T22:59:43-07:00
New Revision: 9ccb6024a0d0af7e2484b67efa036c0d790c5108

URL: https://github.com/llvm/llvm-project/commit/9ccb6024a0d0af7e2484b67efa036c0d790c5108
DIFF: https://github.com/llvm/llvm-project/commit/9ccb6024a0d0af7e2484b67efa036c0d790c5108.diff

LOG: [NFC][sanitizer] Add a few consts

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h
    compiler-rt/lib/sanitizer_common/sanitizer_flat_map.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h
index 38d2a7d117fb..e736796c77b6 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h
@@ -198,7 +198,7 @@ class SizeClassAllocator32 {
     return GetSizeClass(p) != 0;
   }
 
-  uptr GetSizeClass(const void *p) {
+  uptr GetSizeClass(const void *p) const {
     return possible_regions[ComputeRegionId(reinterpret_cast<uptr>(p))];
   }
 
@@ -251,7 +251,7 @@ class SizeClassAllocator32 {
 
   // Iterate over all existing chunks.
   // The allocator must be locked when calling this function.
-  void ForEachChunk(ForEachChunkCallback callback, void *arg) {
+  void ForEachChunk(ForEachChunkCallback callback, void *arg) const {
     for (uptr region = 0; region < kNumPossibleRegions; region++)
       if (possible_regions[region]) {
         uptr chunk_size = ClassIdToSize(possible_regions[region]);

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_flat_map.h b/compiler-rt/lib/sanitizer_common/sanitizer_flat_map.h
index 3040a1f28c2d..ab9e0ebee6dd 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_flat_map.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_flat_map.h
@@ -41,7 +41,7 @@ class FlatMap {
     CHECK_EQ(0U, map_[idx]);
     map_[idx] = val;
   }
-  u8 operator[](uptr idx) {
+  u8 operator[](uptr idx) const {
     CHECK_LT(idx, kSize);
     // FIXME: CHECK may be too expensive here.
     return map_[idx];


        


More information about the llvm-commits mailing list