@@ -207,18 +207,7 @@ template<typename T> static inline void AddAttribute(T *t, unsigned Index, Attri
207
207
#if LLVM_VERSION_LT(14, 0)
208
208
t->addAttribute (Index, Attr);
209
209
#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);
222
211
#endif
223
212
}
224
213
@@ -241,18 +230,7 @@ static inline void AddCallAttributes(CallBase *Call, unsigned Index, const AttrB
241
230
#if LLVM_VERSION_LT(14, 0)
242
231
Attrs = Attrs.addAttributes (Call->getContext (), Index, B);
243
232
#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);
256
234
#endif
257
235
Call->setAttributes (Attrs);
258
236
}
@@ -370,18 +348,7 @@ extern "C" void LLVMRustRemoveFunctionAttributes(LLVMValueRef Fn,
370
348
#if LLVM_VERSION_LT(14, 0)
371
349
PALNew = PAL.removeAttributes (F->getContext (), Index, B);
372
350
#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);
385
352
#endif
386
353
F->setAttributes (PALNew);
387
354
}
0 commit comments