[PATCH] D74481: [Debuginfo][NFC] Create common error handlers for DWARFContext.

Alexey Lapshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 13 00:06:11 PST 2020


avl marked an inline comment as done.
avl added inline comments.


================
Comment at: llvm/include/llvm/DebugInfo/DIContext.h:208
+
+  std::function<void(Error)> RecoverableErrorHandler = nullptr;
+  std::function<void(Error)> WarningHandler = nullptr;
----------------
JDevlieghere wrote:
> Could we make the default handlers static members of the DWARFContext and use those instead of nullptr?
i.e. to make:


```
class DWARFContext {
...
 static std::function<void(Error)> RecoverableErrorHandler = defaultErrorHandler;
 static std::function<void(Error)> WarningHandler = defaultWarningHandler;
}

struct DIDumpOptions {
.....
  std::function<void(Error)> RecoverableErrorHandler = DWARFContext::RecoverableErrorHandler;
  std::function<void(Error)> WarningHandler = DWARFContext::WarningHandler;
};

```

The goal of this refactoring is to allow to redefine error handlers. So that, when DWARFContext is used inside the linker, the linker could specify it`s own error handlers. There would be possible to provide custom error handlers to DWARFContext:  either by passing them in the constructor, either by giving them through setters (setRecoverableErrorHandler()) methods. So that concrete instance of  DWARFContext would have custom error handlers. That scheme would not work if RecoverableErrorHandler and WarningHandler were static methods of DWARFContext.

So, I propose that we would not do this.


Additionally, DWARFContext is more specific class than DIDumpOptions. So it would not be good to refer it inside DIDumpOptions. It would probably be necessary to move ErrorHandlers into DIContext if that solution would be taken. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74481





More information about the llvm-commits mailing list