[PATCH] D72590: NFC: Change PointerLikeTypeTraits::NumLowBitsAvailable from enum to static member. This allows GDB pretty printer to find the value.

Christian Sigg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 13 00:34:19 PST 2020


csigg created this revision.
csigg added a reviewer: aprantl.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

NFC: PointerLikeTypeTraits::NumLowBitsAvailable enum > static int


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72590

Files:
  llvm/include/llvm/Support/PointerLikeTypeTraits.h


Index: llvm/include/llvm/Support/PointerLikeTypeTraits.h
===================================================================
--- llvm/include/llvm/Support/PointerLikeTypeTraits.h
+++ llvm/include/llvm/Support/PointerLikeTypeTraits.h
@@ -56,7 +56,8 @@
   static inline void *getAsVoidPointer(T *P) { return P; }
   static inline T *getFromVoidPointer(void *P) { return static_cast<T *>(P); }
 
-  enum { NumLowBitsAvailable = detail::ConstantLog2<alignof(T)>::value };
+  static constexpr int NumLowBitsAvailable =
+      detail::ConstantLog2<alignof(T)>::value;
 };
 
 template <> struct PointerLikeTypeTraits<void *> {
@@ -70,7 +71,7 @@
   ///
   /// All clients should use assertions to do a run-time check to ensure that
   /// this is actually true.
-  enum { NumLowBitsAvailable = 2 };
+  static constexpr int NumLowBitsAvailable = 2;
 };
 
 // Provide PointerLikeTypeTraits for const things.
@@ -83,7 +84,7 @@
   static inline const T getFromVoidPointer(const void *P) {
     return NonConst::getFromVoidPointer(const_cast<void *>(P));
   }
-  enum { NumLowBitsAvailable = NonConst::NumLowBitsAvailable };
+  static constexpr int NumLowBitsAvailable = NonConst::NumLowBitsAvailable;
 };
 
 // Provide PointerLikeTypeTraits for const pointers.
@@ -96,7 +97,7 @@
   static inline const T *getFromVoidPointer(const void *P) {
     return NonConst::getFromVoidPointer(const_cast<void *>(P));
   }
-  enum { NumLowBitsAvailable = NonConst::NumLowBitsAvailable };
+  static constexpr int NumLowBitsAvailable = NonConst::NumLowBitsAvailable;
 };
 
 // Provide PointerLikeTypeTraits for uintptr_t.
@@ -108,7 +109,7 @@
     return reinterpret_cast<uintptr_t>(P);
   }
   // No bits are available!
-  enum { NumLowBitsAvailable = 0 };
+  static constexpr int NumLowBitsAvailable = 0;
 };
 
 /// Provide suitable custom traits struct for function pointers.
@@ -121,7 +122,8 @@
 /// potentially use alignment attributes on functions to satisfy that.
 template <int Alignment, typename FunctionPointerT>
 struct FunctionPointerLikeTypeTraits {
-  enum { NumLowBitsAvailable = detail::ConstantLog2<Alignment>::value };
+  static constexpr int NumLowBitsAvailable =
+      detail::ConstantLog2<Alignment>::value;
   static inline void *getAsVoidPointer(FunctionPointerT P) {
     assert((reinterpret_cast<uintptr_t>(P) &
             ~((uintptr_t)-1 << NumLowBitsAvailable)) == 0 &&


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72590.237589.patch
Type: text/x-patch
Size: 2374 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200113/79182c12/attachment.bin>


More information about the llvm-commits mailing list