@@ -234,14 +234,17 @@ static Attribute::AttrKind fromRust(LLVMRustAttribute Kind) {
234234
235235template <typename T> static inline void AddAttributes (T *t, unsigned Index,
236236 LLVMAttributeRef *Attrs, size_t AttrsLen) {
237- AttrBuilder B (t->getContext ());
238- for (LLVMAttributeRef Attr : makeArrayRef (Attrs, AttrsLen))
239- B.addAttribute (unwrap (Attr));
240237 AttributeList PAL = t->getAttributes ();
241238 AttributeList PALNew;
242239#if LLVM_VERSION_LT(14, 0)
240+ AttrBuilder B;
241+ for (LLVMAttributeRef Attr : makeArrayRef (Attrs, AttrsLen))
242+ B.addAttribute (unwrap (Attr));
243243 PALNew = PAL.addAttributes (t->getContext (), Index, B);
244244#else
245+ AttrBuilder B (t->getContext ());
246+ for (LLVMAttributeRef Attr : makeArrayRef (Attrs, AttrsLen))
247+ B.addAttribute (unwrap (Attr));
245248 PALNew = PAL.addAttributesAtIndex (t->getContext (), Index, B);
246249#endif
247250 t->setAttributes (PALNew);
@@ -253,7 +256,7 @@ template<typename T> static inline void RemoveAttributes(T *t, unsigned Index,
253256 AttributeList PAL = t->getAttributes ();
254257 AttributeList PALNew;
255258#if LLVM_VERSION_LT(14, 0)
256- AttrBuilder B (t-> getContext ()) ;
259+ AttrBuilder B;
257260 for (LLVMRustAttribute RustAttr : makeArrayRef (RustAttrs, RustAttrsLen))
258261 B.addAttribute (fromRust (RustAttr));
259262 PALNew = PAL.removeAttributes (t->getContext (), Index, B);
0 commit comments