[clang][Interp][NFC] Unifty ReadArg() impl in Disasm.cpp

We can use another if constexpr here to make this shorter and easier to
understand.
This commit is contained in:
Timm Bäder 2022-09-23 12:40:44 +02:00
parent f55c4b4ee3
commit 62bf6acae6

View File

@ -21,17 +21,13 @@
using namespace clang;
using namespace clang::interp;
template <typename T>
inline std::enable_if_t<!std::is_pointer<T>::value, T> ReadArg(Program &P,
CodePtr &OpPC) {
return OpPC.read<T>();
}
template <typename T>
inline std::enable_if_t<std::is_pointer<T>::value, T> ReadArg(Program &P,
CodePtr &OpPC) {
uint32_t ID = OpPC.read<uint32_t>();
return reinterpret_cast<T>(P.getNativePointer(ID));
template <typename T> inline T ReadArg(Program &P, CodePtr &OpPC) {
if constexpr (std::is_pointer<T>::value) {
uint32_t ID = OpPC.read<uint32_t>();
return reinterpret_cast<T>(P.getNativePointer(ID));
} else {
return OpPC.read<T>();
}
}
LLVM_DUMP_METHOD void Function::dump() const { dump(llvm::errs()); }