[clang] Handle __declspec() attributes in using
[llvm-project.git] / compiler-rt / lib / orc / run_program_wrapper.cpp
blobbb4edc56655e92f0ed7a8a971372ee82476178ee
1 //===- run_program_wrapper.cpp --------------------------------------------===//
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-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file is a part of the ORC runtime support library.
11 //===----------------------------------------------------------------------===//
13 #include "adt.h"
14 #include "common.h"
15 #include "wrapper_function_utils.h"
17 #include <vector>
19 using namespace __orc_rt;
21 extern "C" int64_t __orc_rt_run_program(const char *JITDylibName,
22 const char *EntrySymbolName, int argc,
23 char *argv[]);
25 ORC_RT_INTERFACE __orc_rt_CWrapperFunctionResult
26 __orc_rt_run_program_wrapper(const char *ArgData, size_t ArgSize) {
27 return WrapperFunction<int64_t(SPSString, SPSString,
28 SPSSequence<SPSString>)>::
29 handle(ArgData, ArgSize,
30 [](const std::string &JITDylibName,
31 const std::string &EntrySymbolName,
32 const std::vector<std::string_view> &Args) {
33 std::vector<std::unique_ptr<char[]>> ArgVStorage;
34 ArgVStorage.reserve(Args.size());
35 for (auto &Arg : Args) {
36 ArgVStorage.push_back(
37 std::make_unique<char[]>(Arg.size() + 1));
38 memcpy(ArgVStorage.back().get(), Arg.data(), Arg.size());
39 ArgVStorage.back()[Arg.size()] = '\0';
41 std::vector<char *> ArgV;
42 ArgV.reserve(ArgVStorage.size() + 1);
43 for (auto &ArgStorage : ArgVStorage)
44 ArgV.push_back(ArgStorage.get());
45 ArgV.push_back(nullptr);
46 return __orc_rt_run_program(JITDylibName.c_str(),
47 EntrySymbolName.c_str(),
48 ArgV.size() - 1, ArgV.data());
50 .release();