Line data Source code
1 : //===---------- ObjectTransformLayer.cpp - Object Transform Layer ---------===//
2 : //
3 : // The LLVM Compiler Infrastructure
4 : //
5 : // This file is distributed under the University of Illinois Open Source
6 : // License. See LICENSE.TXT for details.
7 : //
8 : //===----------------------------------------------------------------------===//
9 :
10 : #include "llvm/ExecutionEngine/Orc/ObjectTransformLayer.h"
11 : #include "llvm/Support/MemoryBuffer.h"
12 :
13 : namespace llvm {
14 : namespace orc {
15 :
16 0 : ObjectTransformLayer::ObjectTransformLayer(ExecutionSession &ES,
17 : ObjectLayer &BaseLayer,
18 0 : TransformFunction Transform)
19 0 : : ObjectLayer(ES), BaseLayer(BaseLayer), Transform(std::move(Transform)) {}
20 :
21 0 : void ObjectTransformLayer::emit(MaterializationResponsibility R,
22 : std::unique_ptr<MemoryBuffer> O) {
23 : assert(O && "Module must not be null");
24 :
25 0 : if (auto TransformedObj = Transform(std::move(O)))
26 0 : BaseLayer.emit(std::move(R), std::move(*TransformedObj));
27 : else {
28 0 : R.failMaterialization();
29 0 : getExecutionSession().reportError(TransformedObj.takeError());
30 : }
31 0 : }
32 :
33 : } // End namespace orc.
34 : } // End namespace llvm.
|