Skip to content

Commit ac9f4f7

Browse files
use attrbuilder to remove attrs in old LLVM
1 parent 91e7e8d commit ac9f4f7

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Diff for: compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,17 @@ template<typename T> static inline void AddAttributes(T *t, unsigned Index,
250250
template<typename T> static inline void RemoveAttributes(T *t, unsigned Index,
251251
LLVMRustAttribute *RustAttrs,
252252
size_t RustAttrsLen) {
253-
AttributeMask Mask;
254-
for (LLVMRustAttribute RustAttr : makeArrayRef(RustAttrs, RustAttrsLen))
255-
Mask.addAttribute(fromRust(RustAttr));
256253
AttributeList PAL = t->getAttributes();
257254
AttributeList PALNew;
258255
#if LLVM_VERSION_LT(14, 0)
259-
PALNew = PAL.removeAttributes(t->getContext(), Index, Mask);
256+
AttrBuilder B(t->getContext());
257+
for (LLVMRustAttribute RustAttr : makeArrayRef(RustAttrs, RustAttrsLen))
258+
B.addAttribute(fromRust(RustAttr));
259+
PALNew = PAL.removeAttributes(t->getContext(), Index, B);
260260
#else
261+
AttributeMask Mask;
262+
for (LLVMRustAttribute RustAttr : makeArrayRef(RustAttrs, RustAttrsLen))
263+
Mask.addAttribute(fromRust(RustAttr));
261264
PALNew = PAL.removeAttributesAtIndex(t->getContext(), Index, Mask);
262265
#endif
263266
t->setAttributes(PALNew);

0 commit comments

Comments
 (0)