@@ -393,13 +393,12 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateLexicalBlock(
393
393
LLVMValueRef Scope,
394
394
LLVMValueRef File,
395
395
unsigned Line,
396
- unsigned Col,
397
- unsigned Discriminator) {
396
+ unsigned Col) {
398
397
return wrap (Builder->createLexicalBlock (
399
398
unwrapDI<DIDescriptor>(Scope),
400
399
unwrapDI<DIFile>(File), Line, Col
401
- #if LLVM_VERSION_MINOR > = 5
402
- , Discriminator
400
+ #if LLVM_VERSION_MINOR = = 5
401
+ , 0
403
402
#endif
404
403
));
405
404
}
@@ -415,7 +414,11 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateStaticVariable(
415
414
bool isLocalToUnit,
416
415
LLVMValueRef Val,
417
416
LLVMValueRef Decl = NULL ) {
417
+ #if LLVM_VERSION_MINOR == 6
418
+ return wrap (Builder->createGlobalVariable (unwrapDI<DIDescriptor>(Context),
419
+ #else
418
420
return wrap (Builder->createStaticVariable (unwrapDI<DIDescriptor>(Context),
421
+ #endif
419
422
Name,
420
423
LinkageName,
421
424
unwrapDI<DIFile>(File),
@@ -665,11 +668,18 @@ extern "C" void LLVMWriteValueToString(LLVMValueRef Value, RustStringRef str) {
665
668
extern " C" bool
666
669
LLVMRustLinkInExternalBitcode (LLVMModuleRef dst, char *bc, size_t len) {
667
670
Module *Dst = unwrap (dst);
671
+ #if LLVM_VERSION_MINOR == 5
668
672
MemoryBuffer* buf = MemoryBuffer::getMemBufferCopy (StringRef (bc, len));
669
673
ErrorOr<Module *> Src = llvm::getLazyBitcodeModule (buf, Dst->getContext ());
674
+ #else
675
+ std::unique_ptr<MemoryBuffer> buf = MemoryBuffer::getMemBufferCopy (StringRef (bc, len));
676
+ ErrorOr<Module *> Src = llvm::getLazyBitcodeModule (std::move (buf), Dst->getContext ());
677
+ #endif
670
678
if (!Src) {
671
679
LLVMRustSetLastError (Src.getError ().message ().c_str ());
680
+ #if LLVM_VERSION_MINOR == 5
672
681
delete buf;
682
+ #endif
673
683
return false ;
674
684
}
675
685
@@ -712,12 +722,26 @@ LLVMRustOpenArchive(char *path) {
712
722
return nullptr ;
713
723
}
714
724
725
+ #if LLVM_VERSION_MINOR >= 6
726
+ ErrorOr<std::unique_ptr<Archive>> archive_or =
727
+ Archive::create (buf_or.get ()->getMemBufferRef ());
728
+
729
+ if (!archive_or) {
730
+ LLVMRustSetLastError (archive_or.getError ().message ().c_str ());
731
+ return nullptr ;
732
+ }
733
+
734
+ OwningBinary<Archive> *ret = new OwningBinary<Archive>(
735
+ std::move (archive_or.get ()), std::move (buf_or.get ()));
736
+ #else
715
737
std::error_code err;
716
738
Archive *ret = new Archive (std::move (buf_or.get ()), err);
717
739
if (err) {
718
740
LLVMRustSetLastError (err.message ().c_str ());
719
- return NULL ;
741
+ return nullptr ;
720
742
}
743
+ #endif
744
+
721
745
return ret;
722
746
}
723
747
#else
@@ -739,7 +763,14 @@ LLVMRustOpenArchive(char *path) {
739
763
#endif
740
764
741
765
extern " C" const char *
766
+ #if LLVM_VERSION_MINOR >= 6
767
+ LLVMRustArchiveReadSection (OwningBinary<Archive> *ob, char *name, size_t *size) {
768
+
769
+ std::unique_ptr<Archive> &ar = ob->getBinary ();
770
+ #else
742
771
LLVMRustArchiveReadSection (Archive *ar, char *name, size_t *size) {
772
+ #endif
773
+
743
774
#if LLVM_VERSION_MINOR >= 5
744
775
Archive::child_iterator child = ar->child_begin (),
745
776
end = ar->child_end ();
@@ -765,7 +796,11 @@ LLVMRustArchiveReadSection(Archive *ar, char *name, size_t *size) {
765
796
}
766
797
767
798
extern " C" void
799
+ #if LLVM_VERSION_MINOR >= 6
800
+ LLVMRustDestroyArchive (OwningBinary<Archive> *ar) {
801
+ #else
768
802
LLVMRustDestroyArchive (Archive *ar) {
803
+ #endif
769
804
delete ar;
770
805
}
771
806
0 commit comments