Files
concrete/compiler/lib/Support
Andi Drebes e76aee7e10 feat(compiler): Add class StreamStringError with a stream interface for llvm::Error
Composing error messages for `llvm::Error` is either done by using
`llvm::createStringError()` with an appropriate format string and
arguments or by writing to a `std::string`-backed
`llvm::raw_string_ostream` and passing the result to
`llvm::make_error<llvm::StringError>()` verbatim.

The new class `StreamStringError` encapsulates the latter solution
into a class with an appropriate stream operator and implicit cast
operators to `llvm::Error` and `llvm::Expected`.

Example usage:

   llvm::Error foo(int i, size_t s, ...) {
      ...
      if(...) {
        return StreamStringError()
               << "Some error message with an integer: "
               << i << " and a size_t: " << s;
      }
      ...
   }
2021-10-29 13:44:34 +02:00
..