brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · 18f8c9b Raw
31 lines · c
1//===- AllocActionTestUtils.h ---------------------------------------------===//2//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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef ORC_RT_UNITTEST_ALLOCACTIONTESTUTILS_H10#define ORC_RT_UNITTEST_ALLOCACTIONTESTUTILS_H11 12#include "SimplePackedSerializationTestUtils.h"13#include "orc-rt/AllocAction.h"14 15#include <optional>16 17template <typename... SPSArgTs> struct MakeAllocAction {18  template <typename... ArgTs>19  static std::optional<orc_rt::AllocAction> from(orc_rt::AllocActionFn Fn,20                                                 ArgTs &&...Args) {21    using SPS = orc_rt::SPSArgList<SPSArgTs...>;22    auto B = orc_rt::WrapperFunctionBuffer::allocate(SPS::size(Args...));23    orc_rt::SPSOutputBuffer OB(B.data(), B.size());24    if (!SPS::serialize(OB, Args...))25      return std::nullopt;26    return orc_rt::AllocAction(Fn, std::move(B));27  }28};29 30#endif // ORC_RT_UNITTEST_ALLOCACTIONTESTUTILS_H31