From 0d0cc4f6a0cb48600f183c382986df1897bdb7dc Mon Sep 17 00:00:00 2001 From: Erik Desjardins Date: Sat, 26 Feb 2022 17:16:01 -0500 Subject: AttrBuilder doesn't take a context in old LLVM --- compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp') diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index 1ba54ca0779..d627af48ba5 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -234,14 +234,17 @@ static Attribute::AttrKind fromRust(LLVMRustAttribute Kind) { template static inline void AddAttributes(T *t, unsigned Index, LLVMAttributeRef *Attrs, size_t AttrsLen) { - AttrBuilder B(t->getContext()); - for (LLVMAttributeRef Attr : makeArrayRef(Attrs, AttrsLen)) - B.addAttribute(unwrap(Attr)); AttributeList PAL = t->getAttributes(); AttributeList PALNew; #if LLVM_VERSION_LT(14, 0) + AttrBuilder B; + for (LLVMAttributeRef Attr : makeArrayRef(Attrs, AttrsLen)) + B.addAttribute(unwrap(Attr)); PALNew = PAL.addAttributes(t->getContext(), Index, B); #else + AttrBuilder B(t->getContext()); + for (LLVMAttributeRef Attr : makeArrayRef(Attrs, AttrsLen)) + B.addAttribute(unwrap(Attr)); PALNew = PAL.addAttributesAtIndex(t->getContext(), Index, B); #endif t->setAttributes(PALNew); @@ -253,7 +256,7 @@ template static inline void RemoveAttributes(T *t, unsigned Index, AttributeList PAL = t->getAttributes(); AttributeList PALNew; #if LLVM_VERSION_LT(14, 0) - AttrBuilder B(t->getContext()); + AttrBuilder B; for (LLVMRustAttribute RustAttr : makeArrayRef(RustAttrs, RustAttrsLen)) B.addAttribute(fromRust(RustAttr)); PALNew = PAL.removeAttributes(t->getContext(), Index, B); -- cgit 1.4.1-3-g733a5