[libc-commits] [libc] 640c857 - [libc] fix readability-identifier-naming in memory_utils/utils.h (#83919)

via libc-commits libc-commits at lists.llvm.org
Tue Mar 5 08:16:53 PST 2024


Author: Nick Desaulniers
Date: 2024-03-05T08:16:50-08:00
New Revision: 640c85748ec823e91a3cd412829f644cf4f10ffc

URL: https://github.com/llvm/llvm-project/commit/640c85748ec823e91a3cd412829f644cf4f10ffc
DIFF: https://github.com/llvm/llvm-project/commit/640c85748ec823e91a3cd412829f644cf4f10ffc.diff

LOG: [libc] fix readability-identifier-naming in memory_utils/utils.h (#83919)

Fixes:

    libc/src/string/memory_utils/utils.h:345:13: warning: invalid case style
    for member 'offset_' [readability-identifier-naming]

Having a trailing underscore for members is a google3 style, not LLVM style.
Removing the underscore is insufficient, as we would then have 2 members with
the same identifier which is not allowed (it is a compile time error). Remove
the getter, and just access the renamed member that's now made public.

Added: 
    

Modified: 
    libc/src/string/memory_utils/op_generic.h
    libc/src/string/memory_utils/utils.h

Removed: 
    


################################################################################
diff  --git a/libc/src/string/memory_utils/op_generic.h b/libc/src/string/memory_utils/op_generic.h
index 28243c7a18163b..90269c0fa8032a 100644
--- a/libc/src/string/memory_utils/op_generic.h
+++ b/libc/src/string/memory_utils/op_generic.h
@@ -453,7 +453,7 @@ template <typename T> struct Memcmp {
     if (LIBC_UNLIKELY(count >= threshold) && helper.not_aligned()) {
       if (auto value = block(p1, p2))
         return value;
-      adjust(helper.offset(), p1, p2, count);
+      adjust(helper.offset, p1, p2, count);
     }
     return loop_and_tail(p1, p2, count);
   }
@@ -533,7 +533,7 @@ template <typename T> struct Bcmp {
     if (LIBC_UNLIKELY(count >= threshold) && helper.not_aligned()) {
       if (auto value = block(p1, p2))
         return value;
-      adjust(helper.offset(), p1, p2, count);
+      adjust(helper.offset, p1, p2, count);
     }
     return loop_and_tail(p1, p2, count);
   }

diff  --git a/libc/src/string/memory_utils/utils.h b/libc/src/string/memory_utils/utils.h
index 6e26e0c6a54dda..79526d19c6b3dc 100644
--- a/libc/src/string/memory_utils/utils.h
+++ b/libc/src/string/memory_utils/utils.h
@@ -336,13 +336,10 @@ LIBC_INLINE void align_to_next_boundary(T1 *__restrict &p1, T2 *__restrict &p2,
 
 template <size_t SIZE> struct AlignHelper {
   LIBC_INLINE AlignHelper(CPtr ptr)
-      : offset_(distance_to_next_aligned<SIZE>(ptr)) {}
+      : offset(distance_to_next_aligned<SIZE>(ptr)) {}
 
-  LIBC_INLINE bool not_aligned() const { return offset_ != SIZE; }
-  LIBC_INLINE uintptr_t offset() const { return offset_; }
-
-private:
-  uintptr_t offset_;
+  LIBC_INLINE bool not_aligned() const { return offset != SIZE; }
+  uintptr_t offset;
 };
 
 LIBC_INLINE void prefetch_for_write(CPtr dst) {


        


More information about the libc-commits mailing list