1
Fork 0

rustc_llvm: replace llvm::makeArrayRef with ArrayRef constructors.

LLVM upstream has deprecated llvm::makeArrayRef and will remove it.
This commit is contained in:
Dmitri Gribenko 2023-01-11 10:39:01 -05:00 committed by Augie Fackler
parent b22c152958
commit 4f0c88f8bd
2 changed files with 13 additions and 12 deletions

View file

@ -28,8 +28,8 @@ extern "C" void LLVMRustCoverageWriteFilenamesSectionToBuffer(
for (size_t i = 0; i < FilenamesLen; i++) { for (size_t i = 0; i < FilenamesLen; i++) {
FilenameRefs.push_back(std::string(Filenames[i])); FilenameRefs.push_back(std::string(Filenames[i]));
} }
auto FilenamesWriter = coverage::CoverageFilenamesSectionWriter( auto FilenamesWriter =
makeArrayRef(FilenameRefs)); coverage::CoverageFilenamesSectionWriter(ArrayRef<std::string>(FilenameRefs));
RawRustStringOstream OS(BufferOut); RawRustStringOstream OS(BufferOut);
FilenamesWriter.write(OS); FilenamesWriter.write(OS);
} }
@ -45,15 +45,16 @@ extern "C" void LLVMRustCoverageWriteMappingToBuffer(
// Convert from FFI representation to LLVM representation. // Convert from FFI representation to LLVM representation.
SmallVector<coverage::CounterMappingRegion, 0> MappingRegions; SmallVector<coverage::CounterMappingRegion, 0> MappingRegions;
MappingRegions.reserve(NumMappingRegions); MappingRegions.reserve(NumMappingRegions);
for (const auto &Region : makeArrayRef(RustMappingRegions, NumMappingRegions)) { for (const auto &Region : ArrayRef<LLVMRustCounterMappingRegion>(
RustMappingRegions, NumMappingRegions)) {
MappingRegions.emplace_back( MappingRegions.emplace_back(
Region.Count, Region.FalseCount, Region.FileID, Region.ExpandedFileID, Region.Count, Region.FalseCount, Region.FileID, Region.ExpandedFileID,
Region.LineStart, Region.ColumnStart, Region.LineEnd, Region.ColumnEnd, Region.LineStart, Region.ColumnStart, Region.LineEnd, Region.ColumnEnd,
Region.Kind); Region.Kind);
} }
auto CoverageMappingWriter = coverage::CoverageMappingWriter( auto CoverageMappingWriter = coverage::CoverageMappingWriter(
makeArrayRef(VirtualFileMappingIDs, NumVirtualFileMappingIDs), ArrayRef<unsigned>(VirtualFileMappingIDs, NumVirtualFileMappingIDs),
makeArrayRef(Expressions, NumExpressions), ArrayRef<coverage::CounterExpression>(Expressions, NumExpressions),
MappingRegions); MappingRegions);
RawRustStringOstream OS(BufferOut); RawRustStringOstream OS(BufferOut);
CoverageMappingWriter.write(OS); CoverageMappingWriter.write(OS);

View file

@ -257,7 +257,7 @@ template<typename T> static inline void AddAttributes(T *t, unsigned Index,
PALNew = PAL.addAttributes(t->getContext(), Index, B); PALNew = PAL.addAttributes(t->getContext(), Index, B);
#else #else
AttrBuilder B(t->getContext()); AttrBuilder B(t->getContext());
for (LLVMAttributeRef Attr : makeArrayRef(Attrs, AttrsLen)) for (LLVMAttributeRef Attr : ArrayRef<LLVMAttributeRef>(Attrs, AttrsLen))
B.addAttribute(unwrap(Attr)); B.addAttribute(unwrap(Attr));
PALNew = PAL.addAttributesAtIndex(t->getContext(), Index, B); PALNew = PAL.addAttributesAtIndex(t->getContext(), Index, B);
#endif #endif
@ -1064,7 +1064,7 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateEnumerator(
LLVMRustDIBuilderRef Builder, const char *Name, size_t NameLen, LLVMRustDIBuilderRef Builder, const char *Name, size_t NameLen,
const uint64_t Value[2], unsigned SizeInBits, bool IsUnsigned) { const uint64_t Value[2], unsigned SizeInBits, bool IsUnsigned) {
return wrap(Builder->createEnumerator(StringRef(Name, NameLen), return wrap(Builder->createEnumerator(StringRef(Name, NameLen),
APSInt(APInt(SizeInBits, makeArrayRef(Value, 2)), IsUnsigned))); APSInt(APInt(SizeInBits, ArrayRef<uint64_t>(Value, 2)), IsUnsigned)));
} }
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateEnumerationType( extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateEnumerationType(
@ -1477,7 +1477,7 @@ extern "C" void LLVMRustAddHandler(LLVMValueRef CatchSwitchRef,
extern "C" OperandBundleDef *LLVMRustBuildOperandBundleDef(const char *Name, extern "C" OperandBundleDef *LLVMRustBuildOperandBundleDef(const char *Name,
LLVMValueRef *Inputs, LLVMValueRef *Inputs,
unsigned NumInputs) { unsigned NumInputs) {
return new OperandBundleDef(Name, makeArrayRef(unwrap(Inputs), NumInputs)); return new OperandBundleDef(Name, ArrayRef<Value*>(unwrap(Inputs), NumInputs));
} }
extern "C" void LLVMRustFreeOperandBundleDef(OperandBundleDef *Bundle) { extern "C" void LLVMRustFreeOperandBundleDef(OperandBundleDef *Bundle) {
@ -1491,8 +1491,8 @@ extern "C" LLVMValueRef LLVMRustBuildCall(LLVMBuilderRef B, LLVMTypeRef Ty, LLVM
Value *Callee = unwrap(Fn); Value *Callee = unwrap(Fn);
FunctionType *FTy = unwrap<FunctionType>(Ty); FunctionType *FTy = unwrap<FunctionType>(Ty);
return wrap(unwrap(B)->CreateCall( return wrap(unwrap(B)->CreateCall(
FTy, Callee, makeArrayRef(unwrap(Args), NumArgs), FTy, Callee, ArrayRef<Value*>(unwrap(Args), NumArgs),
makeArrayRef(*OpBundles, NumOpBundles))); ArrayRef<OperandBundleDef>(*OpBundles, NumOpBundles)));
} }
extern "C" LLVMValueRef LLVMRustGetInstrProfIncrementIntrinsic(LLVMModuleRef M) { extern "C" LLVMValueRef LLVMRustGetInstrProfIncrementIntrinsic(LLVMModuleRef M) {
@ -1537,8 +1537,8 @@ LLVMRustBuildInvoke(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn,
Value *Callee = unwrap(Fn); Value *Callee = unwrap(Fn);
FunctionType *FTy = unwrap<FunctionType>(Ty); FunctionType *FTy = unwrap<FunctionType>(Ty);
return wrap(unwrap(B)->CreateInvoke(FTy, Callee, unwrap(Then), unwrap(Catch), return wrap(unwrap(B)->CreateInvoke(FTy, Callee, unwrap(Then), unwrap(Catch),
makeArrayRef(unwrap(Args), NumArgs), ArrayRef<Value*>(unwrap(Args), NumArgs),
makeArrayRef(*OpBundles, NumOpBundles), ArrayRef<OperandBundleDef>(*OpBundles, NumOpBundles),
Name)); Name));
} }