summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Berlin <dberlin@dberlin.org>2017-03-07 18:47:50 +0000
committerDaniel Berlin <dberlin@dberlin.org>2017-03-07 18:47:50 +0000
commit44b876e2591bd9bb6a989049d6b3524063cbfb9f (patch)
treec8968847b76e4767d2a1e1e3624c033a771bca77
parent48522c9e13866e9e554040f10037dc617023e4f5 (diff)
downloadbcm5719-llvm-44b876e2591bd9bb6a989049d6b3524063cbfb9f.tar.gz
bcm5719-llvm-44b876e2591bd9bb6a989049d6b3524063cbfb9f.zip
Add PointerLikeTypeTraits for const things, as long as there is one for the non-const version. Clang and other users have a number of types they use as pointers, and this avoids having to define both const and non-const versions of PointerLikeTraits.
llvm-svn: 297181
-rw-r--r--llvm/include/llvm/Support/PointerLikeTypeTraits.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/include/llvm/Support/PointerLikeTypeTraits.h b/llvm/include/llvm/Support/PointerLikeTypeTraits.h
index 9ff894edbeb..521a49684e4 100644
--- a/llvm/include/llvm/Support/PointerLikeTypeTraits.h
+++ b/llvm/include/llvm/Support/PointerLikeTypeTraits.h
@@ -60,6 +60,20 @@ public:
enum { NumLowBitsAvailable = 2 };
};
+// Provide PointerLikeTypeTraits for const things.
+template <typename T> class PointerLikeTypeTraits<const T> {
+ typedef PointerLikeTypeTraits<T> NonConst;
+
+public:
+ static inline const void *getAsVoidPointer(const T P) {
+ return NonConst::getAsVoidPointer(P);
+ }
+ static inline const T getFromVoidPointer(const void *P) {
+ return NonConst::getFromVoidPointer(const_cast<void *>(P));
+ }
+ enum { NumLowBitsAvailable = NonConst::NumLowBitsAvailable };
+};
+
// Provide PointerLikeTypeTraits for const pointers.
template <typename T> class PointerLikeTypeTraits<const T *> {
typedef PointerLikeTypeTraits<T *> NonConst;
OpenPOWER on IntegriCloud