[lldb/Reproducer] Correctly instrument enum values
Enum values can be serialized trivially and should not go through the
object registry.
diff --git a/lldb/include/lldb/Utility/ReproducerInstrumentation.h b/lldb/include/lldb/Utility/ReproducerInstrumentation.h
index 75d6604..5b826bb 100644
--- a/lldb/include/lldb/Utility/ReproducerInstrumentation.h
+++ b/lldb/include/lldb/Utility/ReproducerInstrumentation.h
@@ -183,6 +183,11 @@
namespace lldb_private {
namespace repro {
+template <class T>
+struct is_trivially_serializable
+ : std::integral_constant<bool, std::is_fundamental<T>::value ||
+ std::is_enum<T>::value> {};
+
/// Mapping between serialized indices and their corresponding objects.
///
/// This class is used during replay to map indices back to in-memory objects.
@@ -284,7 +289,7 @@
/// Store the returned value in the index-to-object mapping.
template <typename T> void HandleReplayResult(const T &t) {
unsigned result = Deserialize<unsigned>();
- if (std::is_fundamental<T>::value)
+ if (is_trivially_serializable<T>::value)
return;
// We need to make a copy as the original object might go out of scope.
m_index_to_object.AddObjectForIndex(result, new T(t));
@@ -293,7 +298,7 @@
/// Store the returned value in the index-to-object mapping.
template <typename T> void HandleReplayResult(T *t) {
unsigned result = Deserialize<unsigned>();
- if (std::is_fundamental<T>::value)
+ if (is_trivially_serializable<T>::value)
return;
m_index_to_object.AddObjectForIndex(result, t);
}
@@ -573,7 +578,7 @@
/// fundamental types (in which case we serialize its value) and references
/// to objects (in which case we serialize their index).
template <typename T> void Serialize(T &t) {
- if (std::is_fundamental<T>::value) {
+ if (is_trivially_serializable<T>::value) {
m_stream.write(reinterpret_cast<const char *>(&t), sizeof(T));
} else {
unsigned idx = m_tracker.GetIndexForObject(&t);