@@ -234,14 +234,17 @@ static Attribute::AttrKind fromRust(LLVMRustAttribute Kind) {
234
234
235
235
template <typename T> static inline void AddAttributes (T *t, unsigned Index,
236
236
LLVMAttributeRef *Attrs, size_t AttrsLen) {
237
- AttrBuilder B (t->getContext ());
238
- for (LLVMAttributeRef Attr : makeArrayRef (Attrs, AttrsLen))
239
- B.addAttribute (unwrap (Attr));
240
237
AttributeList PAL = t->getAttributes ();
241
238
AttributeList PALNew;
242
239
#if LLVM_VERSION_LT(14, 0)
240
+ AttrBuilder B;
241
+ for (LLVMAttributeRef Attr : makeArrayRef (Attrs, AttrsLen))
242
+ B.addAttribute (unwrap (Attr));
243
243
PALNew = PAL.addAttributes (t->getContext (), Index, B);
244
244
#else
245
+ AttrBuilder B (t->getContext ());
246
+ for (LLVMAttributeRef Attr : makeArrayRef (Attrs, AttrsLen))
247
+ B.addAttribute (unwrap (Attr));
245
248
PALNew = PAL.addAttributesAtIndex (t->getContext (), Index, B);
246
249
#endif
247
250
t->setAttributes (PALNew);
@@ -253,7 +256,7 @@ template<typename T> static inline void RemoveAttributes(T *t, unsigned Index,
253
256
AttributeList PAL = t->getAttributes ();
254
257
AttributeList PALNew;
255
258
#if LLVM_VERSION_LT(14, 0)
256
- AttrBuilder B (t-> getContext ()) ;
259
+ AttrBuilder B;
257
260
for (LLVMRustAttribute RustAttr : makeArrayRef (RustAttrs, RustAttrsLen))
258
261
B.addAttribute (fromRust (RustAttr));
259
262
PALNew = PAL.removeAttributes (t->getContext (), Index, B);
0 commit comments