[Lldb-commits] [PATCH] D77602: [lldb/Reproducers] Support new replay mode: passive replay

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 16 14:31:38 PDT 2020


JDevlieghere 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.
----------------
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`.


================
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()};
----------------
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. 


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

https://reviews.llvm.org/D77602





More information about the lldb-commits mailing list