Skip to content

Commit 6d59017

Browse files
committed
Handle switch to Expected<StringRef> for section name
1 parent aa9d02e commit 6d59017

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/rustllvm/RustWrapper.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,11 +1003,19 @@ inline section_iterator *unwrap(LLVMSectionIteratorRef SI) {
10031003

10041004
extern "C" size_t LLVMRustGetSectionName(LLVMSectionIteratorRef SI,
10051005
const char **Ptr) {
1006+
#if LLVM_VERSION_GE(10, 0)
1007+
auto NameOrErr = (*unwrap(SI))->getName();
1008+
if (!NameOrErr)
1009+
report_fatal_error(NameOrErr.takeError());
1010+
*Ptr = NameOrErr->data();
1011+
return NameOrErr->size();
1012+
#else
10061013
StringRef Ret;
10071014
if (std::error_code EC = (*unwrap(SI))->getName(Ret))
10081015
report_fatal_error(EC.message());
10091016
*Ptr = Ret.data();
10101017
return Ret.size();
1018+
#endif
10111019
}
10121020

10131021
// LLVMArrayType function does not support 64-bit ElementCount

0 commit comments

Comments
 (0)