[Lldb-commits] [PATCH] D41584: Check existence of each required component during construction of LLVMCDisassembler.

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Jan 9 04:31:45 PST 2018

labath requested changes to this revision.
labath added a comment.
This revision now requires changes to proceed.

I think this makes the code hard to read. A much better approach would be to use `Expected<T>` + factory function pattern. So you would have something like:

  Expected<unique_ptr<LLVMCDisassembler>> LLVMCDisassembler::Create(...) {
    if (first_thing_failed)
      return make_string_error("First thing failed");
    return make_unique<LLVMCDisassembler>(...); // can't fail

I think this is much more readable than the lambda approach, and it also allows you to get rid of the IsValid() function, as we only construct valid objects.


More information about the lldb-commits mailing list