[Lldb-commits] [PATCH] D60178: [Reproducers] Capture return values of functions returning by ptr/ref

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Apr 3 01:10:18 PDT 2019


labath added a comment.

I agree that these functions should be recorded. I think the reason that the infrastructure already mostly supports that is that we were modelling constructors as functions that return pointers (and you definitely need to record constructors).



================
Comment at: lldb/include/lldb/Utility/ReproducerInstrumentation.h:678-716
+  template <typename Result> const Result &RecordResult(const Result &r) {
+    UpdateBoundary();
+    if (ShouldCapture()) {
+      assert(!m_result_recorded);
+      m_serializer.SerializeAll(r);
+      m_result_recorded = true;
+    }
----------------
I would expect that all of these could be replaced with one function using universal references. I.e., something like:
```
template<typename Result> Result &&RecordResult(Result &&r) {
...
m_serializer.SerializeAll(r); // No std::forward, as you don't want to move r into this function
...
return std::forward<Result>(r);
}
```

Can you try that out?


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60178/new/

https://reviews.llvm.org/D60178





More information about the lldb-commits mailing list