[PATCH] D63713: WIP: DataExtractor error handling

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 24 11:27:51 PDT 2019


dblaikie added a comment.

I'm kind of thinking a change to the cursor as Greg suggested might be better than wrapping the stream further - and probably using llvm::Error.

& yeah, I think using Error and saying "parsing failures are problems that must be handled" rather than allowing for accidentally ignoring failures,

Amounting to something like this:

  Cursor C;
  DataExtractor D = ...;
  D.getU32(C);
  D.getU64(C);
  ...
  if (Error E = C.getError())
    ...;

That way early exits (if your record type has optional fields, etc) you can't accidentally forget your error checking (because if there's an Error inside the Cursor it'd have to be checked otherwise it'll assert that it's unchecked, etc)

But yeah, that's a huge amount of refactoring to add all the error handling into existing callers.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D63713





More information about the llvm-commits mailing list