Skip to content

Commit 15e8953

Browse files
authored
Merge pull request #637 from JDevlieghere/🍒/8401698fb57ea202c04562b4326526c65b9ccc74
[lldb/Reproducer] Correctly instrument enum values
2 parents 5f1caca + 6c30cad commit 15e8953

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lldb/include/lldb/Utility/ReproducerInstrumentation.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ template <typename... Ts> inline std::string stringify_args(const Ts &... ts) {
181181
namespace lldb_private {
182182
namespace repro {
183183

184+
template <class T>
185+
struct is_trivially_serializable
186+
: std::integral_constant<bool, std::is_fundamental<T>::value ||
187+
std::is_enum<T>::value> {};
188+
184189
/// Mapping between serialized indices and their corresponding objects.
185190
///
186191
/// This class is used during replay to map indices back to in-memory objects.
@@ -279,7 +284,7 @@ class Deserializer {
279284
/// Store the returned value in the index-to-object mapping.
280285
template <typename T> void HandleReplayResult(const T &t) {
281286
unsigned result = Deserialize<unsigned>();
282-
if (std::is_fundamental<T>::value)
287+
if (is_trivially_serializable<T>::value)
283288
return;
284289
// We need to make a copy as the original object might go out of scope.
285290
m_index_to_object.AddObjectForIndex(result, new T(t));
@@ -288,7 +293,7 @@ class Deserializer {
288293
/// Store the returned value in the index-to-object mapping.
289294
template <typename T> void HandleReplayResult(T *t) {
290295
unsigned result = Deserialize<unsigned>();
291-
if (std::is_fundamental<T>::value)
296+
if (is_trivially_serializable<T>::value)
292297
return;
293298
m_index_to_object.AddObjectForIndex(result, t);
294299
}
@@ -565,7 +570,7 @@ class Serializer {
565570
/// fundamental types (in which case we serialize its value) and references
566571
/// to objects (in which case we serialize their index).
567572
template <typename T> void Serialize(T &t) {
568-
if (std::is_fundamental<T>::value) {
573+
if (is_trivially_serializable<T>::value) {
569574
m_stream.write(reinterpret_cast<const char *>(&t), sizeof(T));
570575
} else {
571576
unsigned idx = m_tracker.GetIndexForObject(&t);

0 commit comments

Comments
 (0)