mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
ab125b35b0
Change company name to "rev.ng Labs Srl" in all license headers to reflect changed company name and legal status Add missing license headers to files that didn't have one
49 lines
1.7 KiB
C++
49 lines
1.7 KiB
C++
//
|
|
// Copyright (c) rev.ng Labs Srl. See LICENSE.md for details.
|
|
//
|
|
|
|
#include "FuncOrCallInst.h"
|
|
|
|
using namespace dla;
|
|
using namespace llvm;
|
|
|
|
bool FuncOrCallInst::isNull() const {
|
|
if (holds_alternative<const Function *>(Val))
|
|
return get<const Function *>(Val) == nullptr;
|
|
if (holds_alternative<const CallInst *>(Val))
|
|
return get<const CallInst *>(Val) == nullptr;
|
|
revng_abort("Can only be Function or CallInst");
|
|
}
|
|
|
|
const Value *FuncOrCallInst::getVal() const {
|
|
if (holds_alternative<const Function *>(Val))
|
|
return static_cast<const Value *>(get<const Function *>(Val));
|
|
if (holds_alternative<const CallInst *>(Val))
|
|
return static_cast<const Value *>(get<const CallInst *>(Val));
|
|
revng_abort("Can only be Function or CallInst");
|
|
}
|
|
|
|
const Type *FuncOrCallInst::getRetType() const {
|
|
if (holds_alternative<const Function *>(Val))
|
|
return dla::getRetType(get<const Function *>(Val));
|
|
if (holds_alternative<const CallInst *>(Val))
|
|
return dla::getRetType(get<const CallInst *>(Val));
|
|
revng_abort("Can only be Function or CallInst");
|
|
}
|
|
|
|
unsigned long FuncOrCallInst::arg_size() const {
|
|
if (holds_alternative<const Function *>(Val))
|
|
return dla::arg_size(get<const Function *>(Val));
|
|
if (holds_alternative<const CallInst *>(Val))
|
|
return dla::arg_size(get<const CallInst *>(Val));
|
|
revng_abort("Can only be Function or CallInst");
|
|
}
|
|
|
|
const Value *FuncOrCallInst::getArg(unsigned Idx) const {
|
|
if (holds_alternative<const Function *>(Val))
|
|
return dla::getArgs(get<const Function *>(Val)).begin() + Idx;
|
|
if (holds_alternative<const CallInst *>(Val))
|
|
return *(dla::getArgs(get<const CallInst *>(Val)).begin() + Idx);
|
|
revng_abort("Can only be Function or CallInst");
|
|
}
|