1
Fork 0

RustWrapper: just use the *AtIndex funcs directly

Otherwise we're kind of reimplementing the inverse of the well-named
methods, and that's not a direction we want to go.
This commit is contained in:
Augie Fackler 2021-09-07 16:15:02 -04:00
parent 532bb80f7f
commit 484b79b950

View file

@ -207,18 +207,7 @@ template<typename T> static inline void AddAttribute(T *t, unsigned Index, Attri
#if LLVM_VERSION_LT(14, 0) #if LLVM_VERSION_LT(14, 0)
t->addAttribute(Index, Attr); t->addAttribute(Index, Attr);
#else #else
// TODO(durin42): we should probably surface the explicit functions to Rust t->addAttributeAtIndex(Index, Attr);
// instead of this switch statement?
switch (Index) {
case AttributeList::ReturnIndex:
t->addRetAttr(Attr);
break;
case AttributeList::FunctionIndex:
t->addFnAttr(Attr);
break;
default:
t->addParamAttr(Index-AttributeList::FirstArgIndex, Attr);
}
#endif #endif
} }
@ -241,18 +230,7 @@ static inline void AddCallAttributes(CallBase *Call, unsigned Index, const AttrB
#if LLVM_VERSION_LT(14, 0) #if LLVM_VERSION_LT(14, 0)
Attrs = Attrs.addAttributes(Call->getContext(), Index, B); Attrs = Attrs.addAttributes(Call->getContext(), Index, B);
#else #else
// TODO(durin42): we should probably surface the explicit functions to Rust Attrs = Attrs.addAttributesAtIndex(Call->getContext(), Index, B);
// instead of this switch statement?
switch (Index) {
case AttributeList::ReturnIndex:
Attrs = Attrs.addRetAttributes(Call->getContext(), B);
break;
case AttributeList::FunctionIndex:
Attrs = Attrs.addFnAttributes(Call->getContext(), B);
break;
default:
Attrs = Attrs.addParamAttributes(Call->getContext(), Index-AttributeList::FirstArgIndex, B);
}
#endif #endif
Call->setAttributes(Attrs); Call->setAttributes(Attrs);
} }
@ -370,18 +348,7 @@ extern "C" void LLVMRustRemoveFunctionAttributes(LLVMValueRef Fn,
#if LLVM_VERSION_LT(14, 0) #if LLVM_VERSION_LT(14, 0)
PALNew = PAL.removeAttributes(F->getContext(), Index, B); PALNew = PAL.removeAttributes(F->getContext(), Index, B);
#else #else
// TODO(durin42): we should probably surface the explicit functions to Rust PALNew = PAL.removeAttributesAtIndex(F->getContext(), Index, B);
// instead of this switch statement?
switch (Index) {
case AttributeList::ReturnIndex:
PALNew = PAL.removeRetAttributes(F->getContext(), B);
break;
case AttributeList::FunctionIndex:
PALNew = PAL.removeFnAttributes(F->getContext(), B);
break;
default:
PALNew = PAL.removeParamAttributes(F->getContext(), Index-AttributeList::FirstArgIndex, B);
}
#endif #endif
F->setAttributes(PALNew); F->setAttributes(PALNew);
} }