[Lldb-commits] [PATCH] D59430: Update DwarfDebugInfoEntry to use llvm::Error and llvm::Expected

Zachary Turner via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Mar 15 13:38:06 PDT 2019


zturner marked 3 inline comments as done.
zturner added inline comments.


================
Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp:218
+  assert(offset < cu->GetNextCompileUnitOffset() &&
+         debug_info_data.ValidOffset(offset));
 
----------------
aprantl wrote:
> Should this be a lldb_assert() followed by `return make_error` instead?
I think it's reasonable to treat this as an internal consistency check, where the pre-condition of this function is "offset must be a valid offset".  Similar to indexing an array out of bounds, your `operator[]` implementation would assert that the index you passed is within range.


================
Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp:1170
                                   const dw_offset_t die_offset, Stream &s) {
-  if (dwarf2Data == NULL) {
-    s.PutCString("NULL");
-    return false;
-  }
+  assert(dwarf2Data);
 
----------------
aprantl wrote:
> Instead of passing a pointer and asserting, wouldn't it be better to pass a `SymbolFileDWARF &`?
Yes, but I was trying to keep the change set minimal, and doing so would propagate that change many levels up the callstack until we reach `SymbolFileDwarf`, at which point we would change all calls to pass `*this` instead of `this`.  That's a reasonable change, but should probably be done separately to keep logically separate changes separate.

Note that, long term, we just won't even pass a `SymbolFileDWARF` to this function at all, because if the point is to decouple the high and low level interfaces, then the low-level interface can't know about the high level interface.


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

https://reviews.llvm.org/D59430





More information about the lldb-commits mailing list