Rollup merge of #105555 - krasimirgg:llvm-int-opt-2, r=cuviper

llvm-wrapper: adapt for LLVM API changes

This is a follow-up of 75aec4703d. There, I updated the wrapper to only include llvm/ADT/Optional.h for LLVM version below 16. But I missed updating some of the None references.

Found by our experimental rust + llvm at HEAD bot: https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/15587#0185006b-e0af-49e5-8b06-280ed125ff0d/200-539
This commit is contained in:
Matthias Krüger 2022-12-11 23:36:47 +01:00 committed by GitHub
commit 79f99e7969
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -223,7 +223,11 @@ fromRust(LLVMRustCodeModel Model) {
case LLVMRustCodeModel::Large: case LLVMRustCodeModel::Large:
return CodeModel::Large; return CodeModel::Large;
case LLVMRustCodeModel::None: case LLVMRustCodeModel::None:
#if LLVM_VERSION_LT(16, 0)
return None; return None;
#else
return std::nullopt;
#endif
default: default:
report_fatal_error("Bad CodeModel."); report_fatal_error("Bad CodeModel.");
} }

View File

@ -322,7 +322,13 @@ extern "C" LLVMAttributeRef LLVMRustCreateUWTableAttr(LLVMContextRef C, bool Asy
} }
extern "C" LLVMAttributeRef LLVMRustCreateAllocSizeAttr(LLVMContextRef C, uint32_t ElementSizeArg) { extern "C" LLVMAttributeRef LLVMRustCreateAllocSizeAttr(LLVMContextRef C, uint32_t ElementSizeArg) {
return wrap(Attribute::getWithAllocSizeArgs(*unwrap(C), ElementSizeArg, None)); return wrap(Attribute::getWithAllocSizeArgs(*unwrap(C), ElementSizeArg,
#if LLVM_VERSION_LT(16, 0)
None
#else
std::nullopt
#endif
));
} }
#if LLVM_VERSION_GE(15, 0) #if LLVM_VERSION_GE(15, 0)
@ -717,7 +723,11 @@ static std::optional<DIFile::ChecksumKind> fromRust(LLVMRustChecksumKind Kind) {
#endif #endif
switch (Kind) { switch (Kind) {
case LLVMRustChecksumKind::None: case LLVMRustChecksumKind::None:
#if LLVM_VERSION_LT(16, 0)
return None; return None;
#else
return std::nullopt;
#endif
case LLVMRustChecksumKind::MD5: case LLVMRustChecksumKind::MD5:
return DIFile::ChecksumKind::CSK_MD5; return DIFile::ChecksumKind::CSK_MD5;
case LLVMRustChecksumKind::SHA1: case LLVMRustChecksumKind::SHA1: