[NFC][sanitizer] Add a few consts
authorVitaly Buka <vitalybuka@google.com>
Mon, 11 Oct 2021 05:47:02 +0000 (22:47 -0700)
committerVitaly Buka <vitalybuka@google.com>
Mon, 11 Oct 2021 05:59:43 +0000 (22:59 -0700)
compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h
compiler-rt/lib/sanitizer_common/sanitizer_flat_map.h

index 38d2a7d..e736796 100644 (file)
@@ -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]);
index 3040a1f..ab9e0eb 100644 (file)
@@ -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];