[PATCH] D50807: [Error] Add FileError and DebugErrorInfo helpers

Alexandre Ganea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 15 13:48:27 PDT 2018


aganea created this revision.
aganea added reviewers: zturner, lhames.
Herald added a subscriber: llvm-commits.

Introducing two new error helpers, `FileError` and `DebugErrorInfo`.

`FileError`
-----------

is meant to encapsulate both an `Error` and a file name/path. It should be used in cases where an `Error` occurs deep down the call chain, and we want to return it to the caller along with the file name.

Previously, the caller had to know the file name, and in some cases it was unavailable. An example of this could be the loading of a COFF object (OBJ). Those files kinds can contain an indirection to another PDB or OBJ (precompiled headers) file. If that indirection fails to load for some reason, the caller might not have that indirect file name in hand. For those cases, a `FileError` would be inserted at the right place in the call chain.

Currently `FileError` logs with the following format: ##'{file}': {error}##, such as:  ##'test.bin': no such file or directory##

`DebugErrorInfo`
----------------

is an abstract class to be used when a qualified type is required as the Error, along with an error code and an optional string.

A typical example of `DebugErrorInfo` is when a module needs to provide a specific subset of errors.

---

Usages are illustrated in https://reviews.llvm.org/D50664 (pending).

I'm open to suggestions for better class names.

Tested with asserts enabled to ensure all `Error`s are checked in the unit tests.


Repository:
  rL LLVM

https://reviews.llvm.org/D50807

Files:
  include/llvm/Support/Error.h
  unittests/Support/ErrorTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50807.160905.patch
Type: text/x-patch
Size: 9469 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180815/18bc364b/attachment.bin>


More information about the llvm-commits mailing list