@@ -207,18 +207,7 @@ template<typename T> static inline void AddAttribute(T *t, unsigned Index, Attri
207207#if LLVM_VERSION_LT(14, 0)
208208 t->addAttribute (Index, Attr);
209209#else
210- // TODO(durin42): we should probably surface the explicit functions to Rust
211- // instead of this switch statement?
212- switch (Index) {
213- case AttributeList::ReturnIndex:
214- t->addRetAttr (Attr);
215- break ;
216- case AttributeList::FunctionIndex:
217- t->addFnAttr (Attr);
218- break ;
219- default :
220- t->addParamAttr (Index-AttributeList::FirstArgIndex, Attr);
221- }
210+ t->addAttributeAtIndex (Index, Attr);
222211#endif
223212}
224213
@@ -241,18 +230,7 @@ static inline void AddCallAttributes(CallBase *Call, unsigned Index, const AttrB
241230#if LLVM_VERSION_LT(14, 0)
242231 Attrs = Attrs.addAttributes (Call->getContext (), Index, B);
243232#else
244- // TODO(durin42): we should probably surface the explicit functions to Rust
245- // instead of this switch statement?
246- switch (Index) {
247- case AttributeList::ReturnIndex:
248- Attrs = Attrs.addRetAttributes (Call->getContext (), B);
249- break ;
250- case AttributeList::FunctionIndex:
251- Attrs = Attrs.addFnAttributes (Call->getContext (), B);
252- break ;
253- default :
254- Attrs = Attrs.addParamAttributes (Call->getContext (), Index-AttributeList::FirstArgIndex, B);
255- }
233+ Attrs = Attrs.addAttributesAtIndex (Call->getContext (), Index, B);
256234#endif
257235 Call->setAttributes (Attrs);
258236}
@@ -370,18 +348,7 @@ extern "C" void LLVMRustRemoveFunctionAttributes(LLVMValueRef Fn,
370348#if LLVM_VERSION_LT(14, 0)
371349 PALNew = PAL.removeAttributes (F->getContext (), Index, B);
372350#else
373- // TODO(durin42): we should probably surface the explicit functions to Rust
374- // instead of this switch statement?
375- switch (Index) {
376- case AttributeList::ReturnIndex:
377- PALNew = PAL.removeRetAttributes (F->getContext (), B);
378- break ;
379- case AttributeList::FunctionIndex:
380- PALNew = PAL.removeFnAttributes (F->getContext (), B);
381- break ;
382- default :
383- PALNew = PAL.removeParamAttributes (F->getContext (), Index-AttributeList::FirstArgIndex, B);
384- }
351+ PALNew = PAL.removeAttributesAtIndex (F->getContext (), Index, B);
385352#endif
386353 F->setAttributes (PALNew);
387354}
0 commit comments