在 LLVM 中,如何插入/声明具有可变参数数量的函数
In LLVM, how to insert/declare a function with variable number of arguments?
我正在尝试将调用的函数提取到另一个模块。如果函数具有定义数量的参数,我就成功了。
// 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
只会添加我能够在ArgTys
中使用MyArgs
捕获的参数。
如何验证源函数是否具有可变数量的参数?
如何使用getOrInserFunction声明具有可变参数数量的函数?
根据文档:
-
您可以通过以下方式声明变量参数函数
FunctionType::get(RetTy, ArgTys, true);
(因此,在您的情况下,请更改"TempF"函数的false
参数。
-
您可以查询函数是否正在使用带有该方法的变量参数列表
bool isVarArg() const
相关文章:
- std::带有前向声明的变体
- 如何正确声明变音字母的char8_t?
- c++17通过生成预先声明的类型列表的笛卡尔乘积来生成std::变体
- std变体和正向声明
- C++声明和定义之间拆分默认参数值
- 如何转发声明依赖于变量定义的类,而变体定义又依赖于模板化类?
- 使用带有提升变体的声明递归
- 如何在C 中声明不变的类(Java示例)
- C++我可以使用变量值作为Struct名称来声明Struct吗
- 如何在mpl::list中声明boost递归变体
- 声明成员与否取决于模板形参
- c++ const函数形参.有没有一种方法可以只声明函数的单个签名?
- 将非const引用使用auto-keyword声明的lambda作为实参传递给std::函数形参类型
- 如何正确声明以函数类型作为形参的模板(如std::function)
- 知道声明中模板形参的数量
- 错误:为vector声明迭代器时模板实参1无效
- c++模板声明中的作用域和默认实参:澄清标准
- c++常量函数声明变体
- 指定默认实参的友元声明必须是定义
- 为什么不允许使用不同数量的模板形参的类/结构声明?