diff options
| author | Augie Fackler <augie@google.com> | 2021-09-07 16:15:02 -0400 |
|---|---|---|
| committer | Augie Fackler <augie@google.com> | 2021-09-07 16:15:02 -0400 |
| commit | 484b79b950b1077d1bbfe6c4edf3bfe070d820b4 (patch) | |
| tree | b98364c7ad2df0ce662699b0daab8466dc87c5f9 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | |
| parent | 532bb80f7fd22bbc9896d9233f2a9ed79071716c (diff) | |
| download | rust-484b79b950b1077d1bbfe6c4edf3bfe070d820b4.tar.gz rust-484b79b950b1077d1bbfe6c4edf3bfe070d820b4.zip | |
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.
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
| -rw-r--r-- | compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | 39 |
1 files changed, 3 insertions, 36 deletions
diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index b3143f14d29..3a7af73c87d 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -207,18 +207,7 @@ template<typename T> static inline void AddAttribute(T *t, unsigned Index, Attri #if LLVM_VERSION_LT(14, 0) t->addAttribute(Index, Attr); #else - // TODO(durin42): we should probably surface the explicit functions to Rust - // 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); - } + t->addAttributeAtIndex(Index, Attr); #endif } @@ -241,18 +230,7 @@ static inline void AddCallAttributes(CallBase *Call, unsigned Index, const AttrB #if LLVM_VERSION_LT(14, 0) Attrs = Attrs.addAttributes(Call->getContext(), Index, B); #else - // TODO(durin42): we should probably surface the explicit functions to Rust - // 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); - } + Attrs = Attrs.addAttributesAtIndex(Call->getContext(), Index, B); #endif Call->setAttributes(Attrs); } @@ -370,18 +348,7 @@ extern "C" void LLVMRustRemoveFunctionAttributes(LLVMValueRef Fn, #if LLVM_VERSION_LT(14, 0) PALNew = PAL.removeAttributes(F->getContext(), Index, B); #else - // TODO(durin42): we should probably surface the explicit functions to Rust - // 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); - } + PALNew = PAL.removeAttributesAtIndex(F->getContext(), Index, B); #endif F->setAttributes(PALNew); } |
