================
----------------
JDevlieghere wrote:
The logic looks good, but there's a lot of unnecessary code duplication. The
common base class is abstract, so maybe a templated static helper is the answer:
```
template<typename T>
GetRegisterInfo(const T& reg_info, reg_index, reg_kind) {
const RegisterInfo *array = reg_info.GetRegisterInfo();
const uint32_t length = reg_info.GetRegisterCount();
if (reg_index >= length || reg_kind != eRegisterKindLLDB)
return {};
return array[reg_index];
}
```
and then switch on `m_arch.GetCore()`
```
switch(m_arch.GetCore()) {
case ArchSpec::eCore_riscv32
return GetRegisterInfo(RegisterInfoPOSIX_riscv32(...), reg_index, reg_kind);
...
}
```
https://github.com/llvm/llvm-project/pull/175262
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits