diff --git a/include/llvm/ADT/NullablePtr.h b/include/llvm/ADT/NullablePtr.h index 8ddfd5d20abd..e66c1d08cded 100644 --- a/include/llvm/ADT/NullablePtr.h +++ b/include/llvm/ADT/NullablePtr.h @@ -14,6 +14,7 @@ #ifndef LLVM_ADT_NULLABLEPTR_H #define LLVM_ADT_NULLABLEPTR_H +#include "llvm/Support/type_traits.h" #include #include @@ -25,8 +26,17 @@ namespace llvm { template class NullablePtr { T *Ptr; + struct PlaceHolder {}; + public: NullablePtr(T *P = 0) : Ptr(P) {} + + template + NullablePtr(NullablePtr Other, + typename enable_if< + is_base_of, + PlaceHolder + >::type = PlaceHolder()) : Ptr(Other.getPtrOrNull()) {} bool isNull() const { return Ptr == 0; } bool isNonNull() const { return Ptr != 0; }