Skip to content

Commit 30ec68a

Browse files
committed
Handle removal of llvm::make_unique()
1 parent 3ec3aa7 commit 30ec68a

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

src/rustllvm/ArchiveWrapper.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ extern "C" void LLVMRustDestroyArchive(LLVMRustArchiveRef RustArchive) {
8989
extern "C" LLVMRustArchiveIteratorRef
9090
LLVMRustArchiveIteratorNew(LLVMRustArchiveRef RustArchive) {
9191
Archive *Archive = RustArchive->getBinary();
92+
#if LLVM_VERSION_GE(10, 0)
93+
std::unique_ptr<Error> Err = std::make_unique<Error>(Error::success());
94+
#else
9295
std::unique_ptr<Error> Err = llvm::make_unique<Error>(Error::success());
96+
#endif
9397
auto Cur = Archive->child_begin(*Err);
9498
if (*Err) {
9599
LLVMRustSetLastError(toString(std::move(*Err)).c_str());

src/rustllvm/Linker.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ extern "C" RustLinker*
1818
LLVMRustLinkerNew(LLVMModuleRef DstRef) {
1919
Module *Dst = unwrap(DstRef);
2020

21-
auto Ret = llvm::make_unique<RustLinker>(*Dst);
22-
return Ret.release();
21+
return new RustLinker(*Dst);
2322
}
2423

2524
extern "C" void

src/rustllvm/PassWrapper.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,11 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
863863
int num_modules,
864864
const char **preserved_symbols,
865865
int num_symbols) {
866+
#if LLVM_VERSION_GE(10, 0)
867+
auto Ret = std::make_unique<LLVMRustThinLTOData>();
868+
#else
866869
auto Ret = llvm::make_unique<LLVMRustThinLTOData>();
870+
#endif
867871

868872
// Load each module's summary and merge it into one combined index
869873
for (int i = 0; i < num_modules; i++) {
@@ -1095,7 +1099,11 @@ struct LLVMRustThinLTOBuffer {
10951099

10961100
extern "C" LLVMRustThinLTOBuffer*
10971101
LLVMRustThinLTOBufferCreate(LLVMModuleRef M) {
1102+
#if LLVM_VERSION_GE(10, 0)
1103+
auto Ret = std::make_unique<LLVMRustThinLTOBuffer>();
1104+
#else
10981105
auto Ret = llvm::make_unique<LLVMRustThinLTOBuffer>();
1106+
#endif
10991107
{
11001108
raw_string_ostream OS(Ret->data);
11011109
{

src/rustllvm/RustWrapper.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,7 +1450,11 @@ struct LLVMRustModuleBuffer {
14501450

14511451
extern "C" LLVMRustModuleBuffer*
14521452
LLVMRustModuleBufferCreate(LLVMModuleRef M) {
1453+
#if LLVM_VERSION_GE(10, 0)
1454+
auto Ret = std::make_unique<LLVMRustModuleBuffer>();
1455+
#else
14531456
auto Ret = llvm::make_unique<LLVMRustModuleBuffer>();
1457+
#endif
14541458
{
14551459
raw_string_ostream OS(Ret->data);
14561460
{

0 commit comments

Comments
 (0)