labath added inline comments.

================
Comment at: lldb/include/lldb/Utility/ReproducerInstrumentation.h:305
     if (is_trivially_serializable<T>::value)
-      return;
+      return const_cast<T &>(t);
     // We need to make a copy as the original object might go out of scope.
----------------
JDevlieghere wrote:
> labath wrote:
> > JDevlieghere wrote:
> > > labath wrote:
> > > > What's up with the `const_cast` ? Should this maybe take a `T &t` 
> > > > argument and let `T` be deduced as `const U` when needed?
> > > I need to decode the template instantiation error for the details, but we 
> > > need to return a non-const T. 
> > It would be good to at least know the reason for that, because const_casts 
> > smell..
> The problem is that you cannot cannot bind a non-const lvalue reference of 
> type `T&` to an rvalue of type `T`.
The usual solution to that is to use "universal" references (`<typename T> T 
&&t`) plus careful sprinkling with `std::forward`. Would that work here?

Or a separate overload for const and non-const references?


================
Comment at: lldb/source/API/SBReproducerPrivate.h:80-85
+      FileSpec file = l->GetFile<SBProvider::Info>();
+      static auto error_or_file = llvm::MemoryBuffer::getFile(file.GetPath());
+      if (!error_or_file)
+        return {};
+      static ReplayData r((*error_or_file)->getBuffer());
+      return {r.GetDeserializer(), r.GetRegistry()};
----------------
JDevlieghere wrote:
> labath wrote:
> > Could this be done in the initialization code somewhere (inside 
> > `Reproducer::Initialize`, I guess)? We could avoid static variables and get 
> > better error handling that way...
> Not if we want to keep the `SBProvider` in API instead of Utility. 
Right, of course.

Soo... do it one level higher then? Initialize the object in 
SBReproducer::(Passive)Replay, and use it from here?


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

https://reviews.llvm.org/D77602



_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to