aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/Support
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/Support')
-rw-r--r--include/llvm/Support/DebugLoc.h6
-rw-r--r--include/llvm/Support/ValueHandle.h11
-rw-r--r--include/llvm/Support/type_traits.h29
3 files changed, 39 insertions, 7 deletions
diff --git a/include/llvm/Support/DebugLoc.h b/include/llvm/Support/DebugLoc.h
index 362390f628..6814f63d9e 100644
--- a/include/llvm/Support/DebugLoc.h
+++ b/include/llvm/Support/DebugLoc.h
@@ -66,7 +66,7 @@ namespace llvm {
};
// Specialize DenseMapInfo for DebugLocTuple.
- template<> struct DenseMapInfo<DebugLocTuple> {
+ template<> struct DenseMapInfo<DebugLocTuple> {
static inline DebugLocTuple getEmptyKey() {
return DebugLocTuple(0, 0, ~0U, ~0U);
}
@@ -85,9 +85,9 @@ namespace llvm {
LHS.Line == RHS.Line &&
LHS.Col == RHS.Col;
}
-
- static bool isPod() { return true; }
};
+ template <> struct isPodLike<DebugLocTuple> {static const bool value = true;};
+
/// DebugLocTracker - This class tracks debug location information.
///
diff --git a/include/llvm/Support/ValueHandle.h b/include/llvm/Support/ValueHandle.h
index a9872a7be1..82c3caeb3a 100644
--- a/include/llvm/Support/ValueHandle.h
+++ b/include/llvm/Support/ValueHandle.h
@@ -254,15 +254,18 @@ struct DenseMapInfo<AssertingVH<T> > {
static bool isEqual(const AssertingVH<T> &LHS, const AssertingVH<T> &RHS) {
return LHS == RHS;
}
- static bool isPod() {
+};
+
+template <typename T>
+struct isPodLike<AssertingVH<T> > {
#ifdef NDEBUG
- return true;
+ static const bool value = true;
#else
- return false;
+ static const bool value = false;
#endif
- }
};
+
/// TrackingVH - This is a value handle that tracks a Value (or Value subclass),
/// even across RAUW operations.
///
diff --git a/include/llvm/Support/type_traits.h b/include/llvm/Support/type_traits.h
index ce916b5fcc..1f3f1e4f89 100644
--- a/include/llvm/Support/type_traits.h
+++ b/include/llvm/Support/type_traits.h
@@ -17,6 +17,8 @@
#ifndef LLVM_SUPPORT_TYPE_TRAITS_H
#define LLVM_SUPPORT_TYPE_TRAITS_H
+#include <utility>
+
// This is actually the conforming implementation which works with abstract
// classes. However, enough compilers have trouble with it that most will use
// the one in boost/type_traits/object_traits.hpp. This implementation actually
@@ -24,6 +26,33 @@
namespace llvm {
+/// isPodLike - This is a type trait that is used to determine whether a given
+/// type can be copied around with memcpy instead of running ctors etc.
+template <typename T>
+struct isPodLike {
+ static const bool value = false;
+};
+
+// pointers are all pod-like.
+template <typename T>
+struct isPodLike<T*> { static const bool value = true; };
+
+// builtin types are pod-like as well.
+// There is probably a much better way to do this.
+template <> struct isPodLike<char> { static const bool value = true; };
+template <> struct isPodLike<unsigned> { static const bool value = true; };
+template <> struct isPodLike<unsigned long> { static const bool value = true; };
+template <> struct isPodLike<unsigned long long> {
+ static const bool value = true;
+};
+
+
+// pairs are pod-like if their elements are.
+template<typename T, typename U>
+struct isPodLike<std::pair<T, U> > {
+ static const bool value = isPodLike<T>::value & isPodLike<U>::value;
+};
+
namespace dont_use
{
// These two functions should never be used. They are helpers to