1 //===---------- ObjectTransformLayer.cpp - Object Transform Layer ---------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "llvm/ExecutionEngine/Orc/ObjectTransformLayer.h"
10 #include "llvm/Support/MemoryBuffer.h"
15 char ObjectTransformLayer::ID
;
17 using BaseT
= RTTIExtends
<ObjectTransformLayer
, ObjectLayer
>;
19 ObjectTransformLayer::ObjectTransformLayer(ExecutionSession
&ES
,
20 ObjectLayer
&BaseLayer
,
21 TransformFunction Transform
)
22 : BaseT(ES
), BaseLayer(BaseLayer
), Transform(std::move(Transform
)) {}
24 void ObjectTransformLayer::emit(
25 std::unique_ptr
<MaterializationResponsibility
> R
,
26 std::unique_ptr
<MemoryBuffer
> O
) {
27 assert(O
&& "Module must not be null");
29 // If there is a transform set then apply it.
31 if (auto TransformedObj
= Transform(std::move(O
)))
32 O
= std::move(*TransformedObj
);
34 R
->failMaterialization();
35 getExecutionSession().reportError(TransformedObj
.takeError());
40 BaseLayer
.emit(std::move(R
), std::move(O
));
43 } // End namespace orc.
44 } // End namespace llvm.