我试图将调用的函数提取到另一个模块。如果函数具有定义数量的参数,则表示我成功。
// Create the arguments vector from the my argument list
SmallVector<Type *, sizeof(MyArgs)> ArgTys;
for (Value *V : MyArgs)
ArgTys.push_back(V->getType());
// Just get a void return type
Type *RetTy = Type::getVoidTy(TempContext);
// Create a new function with MyArgs as arguments
Constant *C = TempM->getOrInsertFunction(
"TempF", FunctionType::get(RetTy, ArgTys, false));
但是,如果函数具有可变数量的参数,getOrInsertFunction
只增加了论据,我是能够捕捉与MyArgs
在ArgTys
。
如何验证源函数是否具有可变数量的参数?
如何使用getOrInserFunction声明带有可变数量参数的函数?
根据文档:
您可以通过以下方式声明变量参数函数:
FunctionType::get(RetTy, ArgTys, true);
(因此,在您的情况下,请false
为“ TempF”函数更改该参数。)
您可以查询函数是否在方法中使用了变量参数列表
bool isVarArg() const
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句