mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-02 22:06:05 +00:00
[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:
parent
f55c4b4ee3
commit
62bf6acae6
@ -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()); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user